*****************************************************************************
*       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: St001591

-----------------------------------------------------------------------------
Collection: Integer compositions

-----------------------------------------------------------------------------
Description: The number of graphs with the given composition of multiplicities of Laplacian eigenvalues.

-----------------------------------------------------------------------------
References: 

-----------------------------------------------------------------------------
Code:
def mapping(G):
    if G.num_verts() > 30:
        raise ValueError("Graph too big for this map")
    s = G.spectrum(laplacian=True)
    c = []
    i, o = 0, None
    for v in s:
        if v != o:
            c.append(i)
            i, o = 0, v
        i += 1
    c.append(i)
    return Composition(c[1:])
@cached_function
def preimages(level):
    print("computing preimages for level", level)
    result = dict()
    for el in graphs(level):
        image = mapping(el)
        result[image] = result.get(image, 0) + 1
    return result

def statistic(x):
    return preimages(x.size()).get(x, 0)


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

[1]             => 1
[1,1]           => 1
[2]             => 1
[1,1,1]         => 1
[1,2]           => 1
[2,1]           => 1
[3]             => 1
[1,1,1,1]       => 2
[1,1,2]         => 1
[1,2,1]         => 2
[1,3]           => 1
[2,1,1]         => 1
[2,2]           => 2
[3,1]           => 1
[4]             => 1
[1,1,1,1,1]     => 10
[1,1,1,2]       => 3
[1,1,2,1]       => 2
[1,1,3]         => 1
[1,2,1,1]       => 2
[1,2,2]         => 2
[1,3,1]         => 1
[1,4]           => 1
[2,1,1,1]       => 1
[2,1,2]         => 2
[2,2,1]         => 3
[2,3]           => 2
[3,1,1]         => 1
[3,2]           => 1
[4,1]           => 1
[5]             => 1
[1,1,1,1,1,1]   => 53
[1,1,1,1,2]     => 11
[1,1,1,2,1]     => 1
[1,1,1,3]       => 3
[1,1,2,1,1]     => 13
[1,1,2,2]       => 3
[1,1,3,1]       => 3
[1,1,4]         => 1
[1,2,1,1,1]     => 13
[1,2,1,2]       => 3
[1,2,2,1]       => 6
[1,2,3]         => 2
[1,3,1,1]       => 4
[1,3,2]         => 2
[1,4,1]         => 2
[1,5]           => 1
[2,1,1,1,1]     => 3
[2,1,1,2]       => 1
[2,1,2,1]       => 4
[2,1,3]         => 2
[2,2,1,1]       => 3
[2,2,2]         => 5
[2,3,1]         => 2
[2,4]           => 2
[3,1,1,1]       => 1
[3,1,2]         => 3
[3,2,1]         => 2
[3,3]           => 2
[4,1,1]         => 1
[4,2]           => 2
[5,1]           => 1
[6]             => 1
[1,1,1,1,1,1,1] => 589
[1,1,1,1,1,2]   => 61
[1,1,1,1,2,1]   => 4
[1,1,1,1,3]     => 11
[1,1,1,2,1,1]   => 53
[1,1,1,2,2]     => 3
[1,1,1,3,1]     => 3
[1,1,1,4]       => 3
[1,1,2,1,1,1]   => 42
[1,1,2,1,2]     => 16
[1,1,2,2,1]     => 5
[1,1,2,3]       => 3
[1,1,3,1,1]     => 9
[1,1,3,2]       => 6
[1,1,4,1]       => 2
[1,1,5]         => 1
[1,2,1,1,1,1]   => 40
[1,2,1,1,2]     => 16
[1,2,1,2,1]     => 16
[1,2,1,3]       => 4
[1,2,2,1,1]     => 9
[1,2,2,2]       => 9
[1,2,3,1]       => 3
[1,2,4]         => 2
[1,3,1,1,1]     => 10
[1,3,1,2]       => 5
[1,3,2,1]       => 3
[1,3,3]         => 2
[1,4,1,1]       => 2
[1,4,2]         => 2
[1,5,1]         => 1
[1,6]           => 1
[2,1,1,1,1,1]   => 11
[2,1,1,1,2]     => 4
[2,1,1,2,1]     => 3
[2,1,1,3]       => 1
[2,1,2,1,1]     => 14
[2,1,2,2]       => 6
[2,1,3,1]       => 3
[2,1,4]         => 2
[2,2,1,1,1]     => 3
[2,2,1,2]       => 5
[2,2,2,1]       => 8
[2,2,3]         => 6
[2,3,1,1]       => 2
[2,3,2]         => 3
[2,4,1]         => 2
[2,5]           => 2
[3,1,1,1,1]     => 3
[3,1,1,2]       => 3
[3,1,2,1]       => 2
[3,1,3]         => 3
[3,2,1,1]       => 2
[3,2,2]         => 3
[3,3,1]         => 4
[3,4]           => 2
[4,1,1,1]       => 1
[4,1,2]         => 2
[4,2,1]         => 2
[4,3]           => 2
[5,1,1]         => 1
[5,2]           => 1
[6,1]           => 1
[7]             => 1

-----------------------------------------------------------------------------
Created: Sep 12, 2020 at 09:17 by Martin Rubey

-----------------------------------------------------------------------------
Last Updated: Sep 12, 2020 at 09:17 by Martin Rubey