Hosoya polynomials of hexagonal chains

Implementation

BeginPackage["Hosoya`"];

Needs["DiscreteMath`RSolve`"];

Off[General::spell1, General::spell];

\(alpha::usage = "alpha[s, x] where s is a string over {1,2,3} gives the Hosoya polynomial of the hexagonal chain consisting of Length[s] hexagons where s defines the type (1, 2, or 3) of attachment of consecutive hexagons. The last symbol of s is immaterial."; 
    beta::usage = \*""beta[s, x] is an auxiliary function giving H((Subscript[B, n]), (Subscript[u, n]), x) where (Subscript[B, n]) is the hexagonal chain consisting of n hexagons defined by the string s over {1,2,3} of length n. The last symbol of s is immaterial.""; 
    gamma::usage = \*""gamma[s, x] is an auxiliary function giving H((Subscript[B, n]), (Subscript[v, n]), x) where (Subscript[B, n]) is the hexagonal chain consisting of n hexagons defined by the string s over {1,2,3} of length n. The last symbol of s is immaterial.""; 
    Hosoya::usage = \*""Hosoya[s,n,x] gives the n-th Hosoya polynomial H((Subscript[B, n,])x) where (Subscript[B, n]) is the hexagonal chain consisting of n hexagons defined by the string s repeated indefinitely. Hosoya[s,n,x,k] gives H(\!\(B\_\(dn\\\\\\\\ \\\\ \(+\\\\ \(\(\\\\\)\(\\\\ \)\(k\)\)\)\)\),x) where d is the length of s and k is between 0 and d-1."";\)
\(\(HosoyaGF::usage = \*""HosoyaGF[s,x,z] gives the ordinary generating function Sum[H((Subscript[B, n]),x)(z^n), {n,0,∞}] of Hosoya polynomials H((Subscript[B, n]),x) where (Subscript[B, n]) is the hexagonal chain consisting of n hexagons defined by the string s repeated indefinitely. HosoyaGF[s,x,z,k] gives the generating function Sum[H(\!\(B\_\(dn\\\\\\\\ \\\\ \(+\\\\ \(\(\\\\\)\(\\\\ \)\(k\)\)\)\)\),x)(z^n), {n,0,∞}] where d is the length of s and k is between 0 and d-1."";\)\)
\(\(WienerIndex::usage = \*""WienerIndex[s,n] gives the Wiener index of (Subscript[B, n]), the hexagonal chain consisting of n hexagons defined by the string s repeated indefinitely. WienerIndex[s,n,k] gives the Wiener index of H(\!\(B\_\(dn\\\\\\\\ \\\\ \(+\\\\ \(\(\\\\\)\(\\\\ \)\(k\)\)\)\)\),x) where d is the length of s and k is between 0 and d-1."";\)\)
\(\(HyperWienerIndex::usage = \*""WienerIndex[s,n] gives the hyper-Wiener index of (Subscript[B, n]), the hexagonal chain consisting of n hexagons defined by the string s repeated indefinitely. HyperWienerIndex[s,n,k] gives the hyper-Wiener index of H(\!\(B\_\(dn\\\\\\\\ \\\\ \(+\\\\ \(\(\\\\\)\(\\\\ \)\(k\)\)\)\)\),x) where d is the length of s and k is between 0 and d-1."";\)\)
MakePretty::usage = 
"MakePretty[p,n,x] tries to \
simplify the exponential polynomial p.";
MakePrettyGF::usage = 
"MakePrettyGF[f,z] tries \
to simplify the rational function f.";
MakeTeX::usage = 
"MakeTeX[exp] converts the \
traditional form of expression exp into TeX.";

Begin["`Private`"];

alpha[{}, x_] = 2 + x;
beta[{}, x_] = gamma[{}, x_] = 
          1 + x;

alpha[s_, x_] := 
        Expand[alpha[Drop[s, -1], x] + 
            x (1 + x) (beta[Drop[s, -1], x] + 
                  gamma[Drop[s, -1], x]) + 4 + 3  x + 2  x^2 + 
            x^3];
beta[s_, x_] := 
        Expand[Switch[Last[s], 1, 
            x beta[Drop[s, -1], x] + 1 + x + x^2 + x^3, 2, 
            x^2 beta[Drop[s, -1], x] + (1 + x)^2, 3, 
            x^2 gamma[Drop[s, -1], x] + (1 + x)^2]];
gamma[s_, x_] := 
        Expand[Switch[Last[s], 1, 
            x^2 beta[Drop[s, -1], x] + (1 + x)^2, 2, 
            x^2 gamma[Drop[s, -1], x] + (1 + x)^2, 3, 
            x gamma[Drop[s, -1], x] + 1 + x + x^2 + 
              x^3]];

Hadamard[f_, g_, z_Symbol] := 
        Module[{f1 = Factor[f], g1 = Factor[g], p, q, r, d, c, a, y, 
            dq}, {p, q} = Denominator /@ {f1, g1}; 
dq = 
            Exponent[q, z]; 
r = 
            Resultant[p, Expand[z^dq (q /. z -> y/z)], 
              z]; 
c = 
            CoefficientList[r, y]; 
c = -Rest[c]/
              First[c]; 
d = 
            Length[c]; 
a = 
            Times @@ (Pad[CoefficientList[Series[#, {z, 0, d - 1}], z], 
                      d] & /@ {f, g}); 
Return[
            ToGfn[Rec[c, a], z]]];

ToGfn[Rec[c_List, a_List], z_Symbol] := 
        Module[{i, j, d, zz, z1, r, den, fc}, 
          d = Length[c]; 
zz = 
            Table[z^i, {i, d}]; 
z1 = 
            If[zz =!= {}, Drop[zz, -1], zz]; 
r = 
            Factor[((a . 
                      Table[z^i - 
                          Take[c, d - i - 1] . 
                            Take[z1, -(d - i - 1)], {i, 0, 
                          d - 1}]))/(1 - 
                    c . zz)]; 
Return[
            r]];

Pad[l_List, 
          d_Integer?(# ≥ 0 &)] := 
  
Module[{k = Length[l]}, 
          If[d ≤ k, l, 
            Join[l, Table[0, {d - k}]]]];

\(\(HosoyaGF[s_, x_, z_] := 
        Module[{m = Length[s], bvars, b, n, gvars, g, vars, 
            inh1 = 1 + x + x^2 + x^3, inh2 = \((1 + x)\)^2, beqns, i, j, 
            lowerb, lowerg, geqns, inits, eqns, sol, gfb, gfg, 
            gfa}, 
bvars = \(\(b[#]\)[n] &\) /@ 
              Range[m]; 
gvars = \(\(g[#]\)[n] &\) /@ 
              Range[m]; 
vars = Join[bvars, gvars]; 
          beqns = Table[\(b[i]\)[
                  n] == \((lowerb = 
                    If[i > 1, \(b[i - 1]\)[n], \(b[m]\)[n - 1]]; 
                  lowerg = If[i > 1, \(g[i - 1]\)[n], \(g[m]\)[n - 1]]; 
                  Switch[s[\([i]\)], 1, x\ lowerb + inh1, 2, 
                    x^2\ lowerb + inh2, 3, x^2\ lowerg + inh2])\), {i, m}]; 
          geqns = Table[\(g[i]\)[
                  n] == \((lowerb = 
                    If[i > 1, \(b[i - 1]\)[n], \(b[m]\)[n - 1]]; 
                  lowerg = If[i > 1, \(g[i - 1]\)[n], \(g[m]\)[n - 1]]; 
                  Switch[s[\([i]\)], 1, x^2\ lowerb + inh2, 2, 
                    x^2\ lowerg + inh2, 3, x\ lowerg + inh1])\), {i, m}]; 
          inits = Join[{\(b[m]\)[0] == 1 + x, \(g[m]\)[0] == 
                  1 + x}, 
              Join @@ Table[{\(b[i]\)[0] == 0, \(g[i]\)[0] == 
                      0}, {i, m - 1}]]; 
          eqns = Join[inits, beqns, geqns]; 
sol = 
            GeneratingFunction[eqns, vars, n, z]; 
sol = 
            Factor[sol[\([1]\)]]; 
gfb = 
            Factor[Sum[
                  z^\((j - 1)\)\ \((sol[\([j]\)] /. z -> z^m)\), {j, m}]/
                z^\((m - 1)\)]; 
          gfg = Factor[
              Sum[z^\((j - m - 1)\)\ \((sol[\([j]\)] /. z -> z^m)\), {j, 
                    m + 1, 2  m}]/z^\((m - 1)\)]; 
          gfa = Factor[\((2 + x + x \((1 + x)\) z \((gfb + gfg)\))\)/\((1 - 
                      z)\) + z \((4 + 3  x + 2  x^2 + x^3)\)/\((1 - z)\)^2]; 
          Return[gfa]];\)
\)
Hosoya[s_, nn_, x_] := 
        Module[{n}, 
SeriesTerm[
              HosoyaGF[s, x, z], {z, 0, n}] /. 
            n -> nn];

HosoyaGF[s_, x_, z_, k_] /; 
          0 ≤ k ≤ Length[s] - 1 := 
        Module[{ls = Length[s], gf = HosoyaGF[s, x, z], num, den, q, r, 
            qlist, full}, 
{num, den} = {Numerator[gf], 
              Denominator[gf]}; 
{q, 
              r} = {PolynomialQuotient[num, den, z], 
              PolynomialRemainder[num, den, z]}; 
qlist = 
            CoefficientList[q, z]; 
          full =  (qlist Pad[
                      CoefficientList[
                        Series[
                          z^k/(1 - z^ls), {z, 0, Length[qlist] - 1}], z], 
                      Length[qlist]]) . z^Range[0, Length[qlist] - 1] + 
              Hadamard[r/den, z^k/(1 - z^ls), 
                z]; 
full = 
            ExpandDenominator[ExpandNumerator[Cancel[full/z^k]]] /. 
              z^m_.  -> z^(m/ls); 
Return[
            Factor[full]]];

Hosoya[s_, nn_, x_, k_] /; 
          0 ≤ k ≤ Length[s] - 1 := 
        Module[{n}, 
SeriesTerm[
              HosoyaGF[s, x, z, k], {z, 0, n}] /. 
            n -> nn];

WienerIndex[s_, nn_] := 
        Module[{n, x, 
            z}, 
SeriesTerm[
              Factor[D[HosoyaGF[s, x, z], x] /. x -> 1], {z, 0, n}] /. 
            n -> nn];

WienerIndex[s_, nn_,  k_] /; 
          0 ≤ k ≤ Length[s] - 1 := 
        Module[{n, x, 
            z}, 
SeriesTerm[
              Factor[D[HosoyaGF[s, x, z, k], x] /. x -> 1], {z, 0, n}] /. 
            n -> nn];

HyperWienerIndex[s_, nn_] := 
        Module[{n, x, z, p}, 
p = 
            HosoyaGF[s, x, z]; 
SeriesTerm[
              Factor[(D[p, x] + D[p, {x, 2}]/2) /. x -> 1], {z, 0, 
                n}] /. n -> 
              nn];

HyperWienerIndex[s_, nn_,  k_] /; 
          0 ≤ k ≤ Length[s] - 1 := 
        Module[{n, x, z, p}, 
p = 
            HosoyaGF[s, x, z, k]; 
SeriesTerm[
              Factor[(D[p, x] + D[p, {x, 2}]/2) /. x -> 1], {z, 0, 
                n}] /. n -> nn];

MakePretty[p_, n_, x_] := 
        Module[{pp = Factor[p], num, den, nfree, 
            nfull}, 
num = 
            Expand[Numerator[pp]]; 
den = 
            Factor[Expand[Denominator[pp]]]; 
nfree = 
            Select[num, FreeQ[#, n] &]; 
nfull = 
            Collect[num - nfree, {n, 
                x^n, (-1)^n}]; 
num = 
            Factor[nfree] + Factor /@ nfull; 
Return[
            TraditionalForm[num/den]]];

MakePrettyGF[p_, z_] := 
        Module[{num = Numerator[p], den = Denominator[p]}, 
          Return[TraditionalForm[
              Collect[num, z]/
                den]]];

MakeTeX[x_] := 
        TeXForm[TraditionalForm[x]];

On[General::spell1, 
        General::spell];

End[];

EndPackage[];

Functions provided by this package

?alpha

?beta

?gamma

?Hosoya

?HosoyaGF

?MakePretty

?MakePrettyGF

?MakeTeX

?WienerIndex

?HyperWienerIndex

Test examples for beta and gamma

alpha[{}, x]

alpha[{bla}, x]

alpha[{1, bla}, x]

alpha[{2, bla}, x]

alpha[{3, bla}, x]

alpha[{2, 1, bla}, x]

alpha[{2, 2, bla}, x]

alpha[{2, 3, bla}, x]

beta[{1}, x]

beta[{2}, x]

beta[{3}, x]

beta[{}, x]

beta[{1, 1, 3, 1, 3, 1}, x]

beta[{2, 1, 3, 1, 3, 1}, x]

beta[{3, 1, 3, 1, 3, 1}, x]

2*

HosoyaGF[{2}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{2}, n, x]

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 4}] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 2}, x], alpha[{2, 2, 2}, x], 
      alpha[{2, 2, 2, 2}, x]}

% - %% // Expand

WienerIndex[{2}, n]

% // MakeTeX

HyperWienerIndex[{2}, n]

1*

HosoyaGF[{1}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{1}, n, x]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 6}] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 1}, x], alpha[{2, 1, 1}, x], 
      alpha[{2, 1, 1, 1}, x], alpha[{2, 1, 1, 1, 1}, x], 
      alpha[{2, 1, 1, 1, 1, 1}, x]}

% - %% // Expand

WienerIndex[{1}, n]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

HyperWienerIndex[{1}, n]

% /. _UnitStep -> 1 // Factor

(13)*

HosoyaGF[{1, 3}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{1, 3}, n, x]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 6}] // Factor

{alpha[{}, x], alpha[{1}, x], alpha[{1, 3}, x], alpha[{1, 3, 1}, x], 
      alpha[{1, 3, 1, 3}, x], alpha[{1, 3, 1, 3, 1}, x], 
      alpha[{1, 3, 1, 3, 1, 3}, x]}

% - %% // Expand

WienerIndex[{1, 3}, n]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

HyperWienerIndex[{1, 3}, n]

% /. _UnitStep -> 1 // Factor

(2123)*

HosoyaGF[{2, 1, 2, 3}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{2, 1, 2, 3}, n, x]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 6}] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 1}, x], alpha[{2, 1, 2}, x], 
      alpha[{2, 1, 2, 3}, x], alpha[{2, 1, 2, 3, 2}, x], 
      alpha[{2, 1, 2, 3, 2, 1}, x]}

% - %% // Expand

WienerIndex[{2, 1, 2, 3}, n]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

HyperWienerIndex[{2, 1, 2, 3}, n]

% /. _UnitStep -> 1 // Factor

(221223)* (conditional form only)

HosoyaGF[{2, 2, 1, 2, 2, 3}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Series[%%, {z, 0, 6}]

CoefficientList[%, z] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 2}, x], alpha[{2, 2, 1}, x], 
      alpha[{2, 2, 1, 2}, x], alpha[{2, 2, 1, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3}, x]}

% - %% // Expand

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 0]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{}, x], alpha[{2, 2, 1, 2, 2, 3}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3}, x]}

% - %%

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 1]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2}, x], alpha[{2, 2, 1, 2, 2, 3, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 2}, x]}

% - %%

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 2]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2, 2}, x], alpha[{2, 2, 1, 2, 2, 3, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 2, 2}, x]}

% - %%

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 3]

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2, 2, 1}, x], alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 2, 2, 1}, x]}

% - %%

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 4]

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2, 2, 1, 2}, x], alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 2, 2, 1, 2}, x]}

% - %%

Hosoya[{2, 2, 1, 2, 2, 3}, n, x, 5]

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2, 2, 1, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2}, 
        x]}

% - %%

WienerIndex[{2, 2, 1, 2, 2, 3}, n]

% /. _UnitStep -> 1 // Factor

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 0]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 1]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 2]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 3]

% // Factor

% // MakeTeX

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 4]

% // Factor

% // MakeTeX

WienerIndex[{2, 2, 1, 2, 2, 3}, n, 5]

% // Factor

% // MakeTeX

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 0]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 1]

% /. _UnitStep -> 1 // Factor

% // Expand

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 2]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 3]

% // Expand

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 4]

HyperWienerIndex[{2, 2, 1, 2, 2, 3}, n, 5]

% // Expand

(21)*

HosoyaGF[{2, 1}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{2, 1}, n, x]

% /. _UnitStep -> 1

MakePretty[%, n, x]

(1/(4 (((x - 1))^2) ((((x^2) + x + 1))^2))) (2 (((x + 1))^5) (Collect[(((-1))^n) (x^2) + 
                    (x^2) - (((-1))^n) (x^(3/2)) + 
                    (x^(3/2)) - (((-1))^n) (Sqrt[x]) + (Sqrt[x]) + (((-1))^n) + 1, (-1)^n]) (x^(((3 n)/2) + 2)) + 5 (x^14) + 10 (x^13) + 
            4 (x^12) - 11 (x^11) - 22 (x^10) - 18 (x^9) - 18 (x^8) - 
            26 (x^7) - 35 (x^6) - 52 (x^5) - 
            54 (x^4) - (((-1))^n) (((x - 1))^2) (((x + 1))^3) ((x^2) + x + 1) ((x^4) + 1) (x^3) - 43 (x^3) - 8 (x^2) + 4 x - 
            2 n (x - 1) ((x^2) + 1) ((x^2) + x + 1) ((x^9) + 
                  2 (x^8) + (x^7) + (x^5) + (x^3) + 8 (x^2) + 10 x + 8) + 
            8) // TraditionalForm

% // MakeTeX

Table[%%, {n, 0, 6}] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 1}, x], alpha[{2, 1, 2}, x], 
      alpha[{2, 1, 2, 1}, x], alpha[{2, 1, 2, 1, 2}, x], 
      alpha[{2, 1, 2, 1, 2, 1}, x]}

% - %% // Expand

WienerIndex[{2, 1}, n]

% /. _UnitStep -> 1 // Factor

Collect[%, (-1)^n]

Factor[Take[%, 4]] + Factor[Drop[%, 4]]

% // MakeTeX

HyperWienerIndex[{2, 1}, n]

% /. _UnitStep -> 1 // Factor

% /. (-1)^n -> 1

% // Factor

HyperWienerIndex[{2, 1}, n, 0]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{2, 1}, n, 1]

% /. _UnitStep -> 1 // Factor

% // Expand

(221)* (conditional form only)

HosoyaGF[{2, 2, 1}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Series[%%, {z, 0, 6}]

CoefficientList[%, z] // Factor

{alpha[{}, x], alpha[{2}, x], alpha[{2, 2}, x], alpha[{2, 2, 1}, x], 
      alpha[{2, 2, 1, 2}, x], alpha[{2, 2, 1, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 1}, x]}

% - %% // Expand

Hosoya[{2, 2, 1}, n, x, 0]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{}, x], alpha[{2, 2, 1}, x], 
      alpha[{2, 2, 1, 2, 2, 1}, x]}

% - %%

Hosoya[{2, 2, 1}, n, x, 1]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2}, x], alpha[{2, 2, 1, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 1, 2}, x]}

% - %%

Hosoya[{2, 2, 1}, n, x, 2]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{2, 2}, x], alpha[{2, 2, 1, 2, 2}, x], 
      alpha[{2, 2, 1, 2, 2, 1, 2, 2}, x]}

% - %%

WienerIndex[{2, 2, 1}, n]

% /. _UnitStep -> 1 // Factor

WienerIndex[{2, 2, 1}, n, 0]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{2, 2, 1}, n, 1]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{2, 2, 1}, n, 2]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

HyperWienerIndex[{2, 2, 1}, n, 0]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{2, 2, 1}, n, 1]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{2, 2, 1}, n, 2]

% /. _UnitStep -> 1 // Factor

(1133)*

HosoyaGF[{1, 1, 3, 3}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Hosoya[{1, 1, 3, 3}, n, x]

% /. _UnitStep -> 1

MakePretty[%, n, x]

(1/(4 (((x - 1))^2) ((((x^2) + x + 1))^2))) (2 (((x + 1))^4) ((x^2) + 
                  1) (Collect[(((-1))^n) (x^2) + 
                    (x^2) - (((-1))^n) (x^(3/2)) + 
                    (x^(3/2)) - (((-1))^n) (Sqrt[x]) + (Sqrt[x]) + (((-1))^n) + 1, (-1)^n]) (x^(((3 n)/2) + 1)) + (x^12) - (x^11) - 6 (x^10) - 
            7 (x^9) - 6 (x^8) - 11 (x^7) - 38 (x^6) - 
            73 (x^5) - (((-1))^n) (((x - 1))^2) (((x + 1))^4) ((x^2) + x + 1) (x^4) - 71 (x^4) - 48 (x^3) - 8 (x^2) + 4 x - 
            2 n (x - 1) ((x^2) + x + 1) ((x^9) + (x^8) + 5 (x^5) + 
                  11 (x^4) + 12 (x^3) + 16 (x^2) + 10 x + 8) + 8) // 
      TraditionalForm

% // MakeTeX

Table[%%, {n, 0, 6}] // Factor

{alpha[{}, x], alpha[{1}, x], alpha[{1, 1}, x], alpha[{1, 1, 3}, x], 
      alpha[{1, 1, 3, 3}, x], alpha[{1, 1, 3, 3, 1}, x], 
      alpha[{1, 1, 3, 3, 1, 1}, x]}

% - %% // Expand

WienerIndex[{1, 1, 3, 3}, n]

% /. _UnitStep -> 1 // Factor

Collect[%, (-1)^n]

Factor[Take[%, 4]] + Factor[Drop[%, 4]]

% // MakeTeX

HyperWienerIndex[{1, 1, 3, 3}, n]

% /. _UnitStep -> 1 // Factor

% /. (-1)^n -> 1  // Factor

%% /. (-1)^n -> (-1)  // Factor

(111333)* (conditional form only)

HosoyaGF[{1, 1, 1, 3, 3, 3}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Series[%%, {z, 0, 6}]

CoefficientList[%, z] // Factor

{alpha[{}, x], alpha[{1}, x], alpha[{1, 1}, x], alpha[{1, 1, 1}, x], 
      alpha[{1, 1, 1, 3}, x], alpha[{1, 1, 1, 3, 3}, x], 
      alpha[{1, 1, 1, 3, 3, 3}, x]}

% - %% // Expand

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 0]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Table[%%, {n, 0, 2}] // Factor

{alpha[{}, x], alpha[{1, 1, 1, 3, 3, 3}, x], 
      alpha[{1, 1, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3}, x]}

% - %%

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 1]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 2]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 3]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 4]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 1, 3, 3, 3}, n, x, 5]

MakePretty[%, n, x]

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n]

% /. _UnitStep -> 1 // Factor

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 0]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 1]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 2]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 3]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 4]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 3, 3, 3}, n, 5]

% // Factor

% // MakeTeX

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 0]

% /. _UnitStep -> 1 // Factor

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 1]

% // Expand

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 2]

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 3]

% // Expand

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 4]

HyperWienerIndex[{1, 1, 1, 3, 3, 3}, n, 5]

% // Expand

(1122)* (conditional form only)

HosoyaGF[{1, 1, 2, 2}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Series[%%, {z, 0, 6}]

CoefficientList[%, z] // Factor

{alpha[{}, x], alpha[{1}, x], alpha[{1, 1}, x], alpha[{1, 1, 2}, x], 
      alpha[{1, 1, 2, 2}, x], alpha[{1, 1, 2, 2, 1}, x], 
      alpha[{1, 1, 2, 2, 1, 1}, x]}

% - %% // Expand

Hosoya[{1, 1, 2, 2}, n, x, 0]

% /. _UnitStep -> 1

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 2, 2}, n, x, 1]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 2, 2}, n, x, 2]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 2, 2}, n, x, 3]

MakePretty[%, n, x]

% // MakeTeX

WienerIndex[{1, 1, 2, 2}, n]

% /. _UnitStep -> 1 // Factor

WienerIndex[{1, 1, 2, 2}, n, 0]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{1, 1, 2, 2}, n, 1]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 2, 2}, n, 2]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 2, 2}, n, 3]

% // Factor

% // MakeTeX

(111222)* (conditional form only)

HosoyaGF[{1, 1, 1, 2, 2, 2}, x, z]

MakePrettyGF[%, z]

% // MakeTeX

Series[%%, {z, 0, 6}]

CoefficientList[%, z] // Factor

{alpha[{}, x], alpha[{1}, x], alpha[{1, 1}, x], alpha[{1, 1, 1}, x], 
      alpha[{1, 1, 1, 2}, x], alpha[{1, 1, 1, 2, 2}, x], 
      alpha[{1, 1, 1, 2, 2, 2}, x]}

% - %% // Expand

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 0]

% /. _UnitStep -> 1

MakePretty[%, n, x]

MakeTeX[%]

Table[%%, {n, 0, 2}] // Factor

{alpha[{}, x], alpha[{1, 1, 1, 2, 2, 2}, x], 
      alpha[{1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2}, x]}

% - %% // Expand

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 1]

MakePretty[%, n, x]

% // MakeTeX

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 2] // MakePretty

% // MakeTeX

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 3] // MakePretty

% // MakeTeX

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 4] // MakePretty

% // MakeTeX

Hosoya[{1, 1, 1, 2, 2, 2}, n, x, 5] // MakePretty

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n]

% /. _UnitStep -> 1 // Factor

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 0]

% /. _UnitStep -> 1 // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 1]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 2]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 3]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 4]

% // Factor

% // MakeTeX

WienerIndex[{1, 1, 1, 2, 2, 2}, n, 5]

% // Factor

% // MakeTeX

HyperWienerIndex[{1, 1, 1, 2, 2, 2}, n, 5]

% // Factor

Denominators of generating functions of modular Hosoya polynomials

Denominator[HosoyaGF[{1, 1, 1, 2, 2, 2}, x, z, 0]]

Denominator[HosoyaGF[{1, 1, 1, 2, 3, 2}, x, z, 0]]

Denominator[HosoyaGF[{1, 2, 1, 2, 3, 2}, x, z, 0]]

Denominator[HosoyaGF[{1, 2, 3, 2, 3, 2}, x, z, 0]]

Denominator[HosoyaGF[{1, 2, 3, 1, 2, 3}, x, z, 0]]

Denominator[HosoyaGF[{1, 1, 1, 1, 1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1, 1, 1, 1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1, 1, 1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1, 1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1}, x, z, 0]]

Denominator[HosoyaGF[{1, 1}, x, z, 0]]

Denominator[HosoyaGF[{1, 2}, x, z, 0]]

Denominator[HosoyaGF[{1, 3}, x, z, 0]]

Denominator[HosoyaGF[{2, 1}, x, z, 0]]

Denominator[HosoyaGF[{2, 2}, x, z, 0]]

Denominator[HosoyaGF[{2, 3}, x, z, 0]]

Denominator[HosoyaGF[{3, 1}, x, z, 0]]

Denominator[HosoyaGF[{3, 2}, x, z, 0]]

Denominator[HosoyaGF[{3, 3}, x, z, 0]]