OFFSET
1,2
COMMENTS
The Wiener index of a connected graph is the sum of distances between all unordered pairs of vertices in the graph.
Extended to a(1)-a(2) using the formula/recurrence. - Eric W. Weisstein, Sep 08 2017
REFERENCES
N. Biggs, Algebraic Graph Theory, 2nd ed. Cambridge University Press, 1993.
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..1000 (corrected by Ray Chandler, Jan 19 2019)
B. E. Sagan, Y-N. Yeh, and P. Zhang, The Wiener Polynomial of a Graph, Internat. J. of Quantum Chem., 60, 1996, 959-969.
Eric Weisstein's World of Mathematics, Moebius Ladder
Eric Weisstein's World of Mathematics, Wiener Index
Index entries for linear recurrences with constant coefficients, signature (2,1,-4,1,2,-1).
FORMULA
a(n) = Sum_{k>=1} k*A180856(n,k).
a(n) = n*(n^2 + 2*n - 2)/2 if n is even;
a(n) = n*(n^2 + 2*n - 1)/2 if n is odd.
a(n) = n*(-3-(-1)^n+4*n+2*n^2)/4. - Colin Barker, Oct 31 2012
G.f.: x*(1 + 4 x + 8 x^2 - x^4)/((-1 + x)^4*(1 + x)^2). - Colin Barker, Oct 31 2012
E.g.f.: x*((2 + 5*x + x^2)*cosh(x) + (1 + 5*x + x^2)*sinh(x))/2. - Stefano Spezia, May 30 2023
EXAMPLE
a(4) = 4*(-3-(-1)^4+4*4+2*4^2)/4 = -3-1+16+32 = 44. - Indranil Ghosh, Feb 24 2017
MAPLE
a := proc (n) if `mod`(n, 2) = 0 then (1/2)*n*(n^2+2*n-2) else (1/2)*n*(n^2+2*n-1) end if end proc: seq(a(n), n = 3 .. 45);
MATHEMATICA
(* Start from Indranil Ghosh, Feb 24 2017 *)
Table[n (-3 - (-1)^n + 4 n + 2 n^2)/4, {n, 40}]
CoefficientList[Series[(1 + 4 x + 8 x^2 - x^4)/((-1 + x)^4 (1 + x)^2), {x, 0, 40}], x]
LinearRecurrence[{2, 1, -4, 1, 2, -1}, {1, 6, 21, 44, 85, 138}, 40]
(* End *)
PROG
(PARI) a(n) = n*(-3-(-1)^n+4*n+2*n^2)/4 \\ Indranil Ghosh, Feb 24 2017
(Python)
def A180857(n):
return n*(-3-(-1)**n+4*n+2*n**2)//4 # Indranil Ghosh, Feb 24 2017
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Emeric Deutsch, Sep 24 2010
EXTENSIONS
a(1)-a(2) from Eric W. Weisstein, Sep 08 2017
STATUS
approved