*****************************************************************************
*       www.FindStat.org - The Combinatorial Statistic Finder               *
*                                                                           *
*       Copyright (C) 2019 The FindStatCrew <info@findstat.org>             *
*                                                                           *
*    This information is distributed in the hope that it will be useful,    *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                   *
*****************************************************************************

-----------------------------------------------------------------------------
Statistic identifier: St000422

-----------------------------------------------------------------------------
Collection: Graphs

-----------------------------------------------------------------------------
Description: The energy of a graph, if it is integral.

The energy of a graph is the sum of the absolute values of its eigenvalues.  This statistic is only defined for graphs with integral energy.  It is known, that the energy is never an odd integer [2].  In fact, it is never the square root of an odd integer [3].

The energy of a graph is the sum of the energies of the connected components of a graph.  The energy of the complete graph $K_n$ equals $2n-2$.  For this reason, we do not define the energy of the empty graph.


-----------------------------------------------------------------------------
References: [1]   [[wikipedia:Graph_energy]]
[2]   Bapat, R. B., Pati, S. Energy of a graph is never an odd integer [[MathSciNet:2250987]]
[3]   Pirzada, S., Gutman, I. Energy of a graph is never the square root of an odd integer [[MathSciNet:2396734]]

-----------------------------------------------------------------------------
Code:
def statistic(G):
    return sum(abs(c) for c in G.spectrum())

-----------------------------------------------------------------------------
Statistic values:

([],1)                                                                                                                              => 0
([],2)                                                                                                                              => 0
([(0,1)],2)                                                                                                                         => 2
([],3)                                                                                                                              => 0
([(1,2)],3)                                                                                                                         => 2
([(0,1),(0,2),(1,2)],3)                                                                                                             => 4
([],4)                                                                                                                              => 0
([(2,3)],4)                                                                                                                         => 2
([(0,3),(1,2)],4)                                                                                                                   => 4
([(1,2),(1,3),(2,3)],4)                                                                                                             => 4
([(0,2),(0,3),(1,2),(1,3)],4)                                                                                                       => 4
([(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)],4)                                                                                           => 6
([],5)                                                                                                                              => 0
([(3,4)],5)                                                                                                                         => 2
([(0,4),(1,4),(2,4),(3,4)],5)                                                                                                       => 4
([(1,4),(2,3)],5)                                                                                                                   => 4
([(2,3),(2,4),(3,4)],5)                                                                                                             => 4
([(1,3),(1,4),(2,3),(2,4)],5)                                                                                                       => 4
([(0,3),(0,4),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                                                     => 6
([(0,1),(2,3),(2,4),(3,4)],5)                                                                                                       => 6
([(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                                                           => 6
([(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                                   => 8
([],6)                                                                                                                              => 0
([(4,5)],6)                                                                                                                         => 2
([(1,5),(2,5),(3,5),(4,5)],6)                                                                                                       => 4
([(2,5),(3,4)],6)                                                                                                                   => 4
([(3,4),(3,5),(4,5)],6)                                                                                                             => 4
([(2,4),(2,5),(3,4),(3,5)],6)                                                                                                       => 4
([(0,5),(1,5),(2,4),(3,4),(4,5)],6)                                                                                                 => 6
([(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                                                     => 6
([(0,5),(1,4),(2,3)],6)                                                                                                             => 6
([(1,2),(3,4),(3,5),(4,5)],6)                                                                                                       => 6
([(0,1),(2,4),(2,5),(3,4),(3,5)],6)                                                                                                 => 6
([(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                                                           => 6
([(0,4),(0,5),(1,2),(1,3),(2,5),(3,4)],6)                                                                                           => 8
([(0,3),(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5)],6)                                                                         => 6
([(0,4),(0,5),(1,2),(1,3),(2,3),(4,5)],6)                                                                                           => 8
([(0,1),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                                                     => 8
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,3),(2,5),(3,4)],6)                                                                         => 8
([(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                                   => 8
([(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                                                       => 8
([(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 10
([],7)                                                                                                                              => 0
([(5,6)],7)                                                                                                                         => 2
([(2,6),(3,6),(4,6),(5,6)],7)                                                                                                       => 4
([(3,6),(4,5)],7)                                                                                                                   => 4
([(4,5),(4,6),(5,6)],7)                                                                                                             => 4
([(0,1),(2,6),(3,6),(4,6),(5,6)],7)                                                                                                 => 6
([(3,5),(3,6),(4,5),(4,6)],7)                                                                                                       => 4
([(1,6),(2,6),(3,5),(4,5),(5,6)],7)                                                                                                 => 6
([(2,5),(2,6),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                                     => 6
([(1,6),(2,5),(3,4)],7)                                                                                                             => 6
([(2,3),(4,5),(4,6),(5,6)],7)                                                                                                       => 6
([(1,2),(3,5),(3,6),(4,5),(4,6)],7)                                                                                                 => 6
([(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                                           => 6
([(0,1),(2,5),(2,6),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                               => 8
([(1,5),(1,6),(2,3),(2,4),(3,6),(4,5)],7)                                                                                           => 8
([(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)],7)                                                                         => 6
([(0,3),(1,2),(4,5),(4,6),(5,6)],7)                                                                                                 => 8
([(0,5),(1,4),(2,3),(3,6),(4,6),(5,6)],7)                                                                                           => 8
([(0,5),(0,6),(1,4),(1,6),(2,3),(2,6),(3,6),(4,6),(5,6)],7)                                                                         => 10
([(1,5),(1,6),(2,3),(2,4),(3,4),(5,6)],7)                                                                                           => 8
([(1,2),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                                     => 8
([(1,4),(1,5),(1,6),(2,3),(2,5),(2,6),(3,4),(3,6),(4,5)],7)                                                                         => 8
([(0,5),(0,6),(1,2),(1,3),(2,3),(4,5),(4,6)],7)                                                                                     => 8
([(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                   => 8
([(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,5),(3,6),(4,5),(4,6)],7)                                                       => 8
([(0,4),(0,5),(1,2),(1,3),(2,5),(2,6),(3,4),(3,6),(4,6),(5,6)],7)                                                                   => 10
([(0,3),(0,4),(0,5),(0,6),(1,2),(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6)],7)                                           => 10
([(0,1),(0,2),(1,2),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                                         => 10
([(0,4),(0,5),(1,2),(1,3),(2,3),(2,6),(3,6),(4,5),(4,6),(5,6)],7)                                                                   => 10
([(0,1),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                                             => 10
([(0,3),(0,4),(0,5),(0,6),(1,2),(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                         => 12
([(1,2),(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7)                                     => 10
([(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(1,2),(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7) => 12

-----------------------------------------------------------------------------
Created: Feb 26, 2016 at 11:47 by Martin Rubey

-----------------------------------------------------------------------------
Last Updated: Feb 26, 2016 at 12:08 by Martin Rubey