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

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

-----------------------------------------------------------------------------
Description: The number of endomorphisms of a graph.

An endomorphism of a graph $(V, E)$ is a map $f: V\to V$ such that for any edge $(u,v)\in E$ also $\big(f(u), f(v)\big)\in E$.

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

-----------------------------------------------------------------------------
Code:
def statistic(G):
    G = G.relabel(inplace=False)
    n = G.num_verts()
    endomorphisms = 0
    for f in cartesian_product([list(range(n)) for _ in range(n)]):
        if all(G.has_edge(f[u], f[v]) for u, v in G.edges(labels=False)):
            endomorphisms += 1
    return endomorphisms


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

([],1)                                                                                          => 1
([],2)                                                                                          => 4
([(0,1)],2)                                                                                     => 2
([],3)                                                                                          => 27
([(1,2)],3)                                                                                     => 6
([(0,2),(1,2)],3)                                                                               => 6
([(0,1),(0,2),(1,2)],3)                                                                         => 6
([],4)                                                                                          => 256
([(2,3)],4)                                                                                     => 32
([(1,3),(2,3)],4)                                                                               => 24
([(0,3),(1,3),(2,3)],4)                                                                         => 30
([(0,3),(1,2)],4)                                                                               => 16
([(0,3),(1,2),(2,3)],4)                                                                         => 16
([(1,2),(1,3),(2,3)],4)                                                                         => 24
([(0,3),(1,2),(1,3),(2,3)],4)                                                                   => 14
([(0,2),(0,3),(1,2),(1,3)],4)                                                                   => 32
([(0,2),(0,3),(1,2),(1,3),(2,3)],4)                                                             => 16
([(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)],4)                                                       => 24
([],5)                                                                                          => 3125
([(3,4)],5)                                                                                     => 250
([(2,4),(3,4)],5)                                                                               => 150
([(1,4),(2,4),(3,4)],5)                                                                         => 150
([(0,4),(1,4),(2,4),(3,4)],5)                                                                   => 260
([(1,4),(2,3)],5)                                                                               => 80
([(1,4),(2,3),(3,4)],5)                                                                         => 80
([(0,1),(2,4),(3,4)],5)                                                                         => 48
([(2,3),(2,4),(3,4)],5)                                                                         => 150
([(0,4),(1,4),(2,3),(3,4)],5)                                                                   => 60
([(1,4),(2,3),(2,4),(3,4)],5)                                                                   => 70
([(0,4),(1,4),(2,3),(2,4),(3,4)],5)                                                             => 48
([(1,3),(1,4),(2,3),(2,4)],5)                                                                   => 160
([(0,4),(1,2),(1,3),(2,4),(3,4)],5)                                                             => 94
([(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                             => 80
([(0,4),(1,3),(2,3),(2,4),(3,4)],5)                                                             => 42
([(0,4),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                       => 50
([(0,3),(0,4),(1,3),(1,4),(2,3),(2,4)],5)                                                       => 180
([(0,3),(0,4),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                 => 66
([(0,4),(1,3),(2,3),(2,4)],5)                                                                   => 42
([(0,1),(2,3),(2,4),(3,4)],5)                                                                   => 48
([(0,3),(1,2),(1,4),(2,4),(3,4)],5)                                                             => 32
([(0,3),(0,4),(1,2),(1,4),(2,4),(3,4)],5)                                                       => 32
([(0,3),(0,4),(1,2),(1,4),(2,3)],5)                                                             => 10
([(0,1),(0,4),(1,3),(2,3),(2,4),(3,4)],5)                                                       => 28
([(0,3),(0,4),(1,2),(1,4),(2,3),(2,4),(3,4)],5)                                                 => 36
([(0,4),(1,2),(1,3),(2,3),(2,4),(3,4)],5)                                                       => 44
([(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                       => 120
([(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                                 => 78
([(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                           => 52
([(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4)],5)                                                 => 48
([(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,4),(3,4)],5)                                           => 64
([(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                                     => 60
([(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5)                               => 120
([],6)                                                                                          => 46656
([(4,5)],6)                                                                                     => 2592
([(3,5),(4,5)],6)                                                                               => 1296
([(2,5),(3,5),(4,5)],6)                                                                         => 1080
([(1,5),(2,5),(3,5),(4,5)],6)                                                                   => 1560
([(0,5),(1,5),(2,5),(3,5),(4,5)],6)                                                             => 3130
([(2,5),(3,4)],6)                                                                               => 576
([(2,5),(3,4),(4,5)],6)                                                                         => 576
([(1,2),(3,5),(4,5)],6)                                                                         => 288
([(3,4),(3,5),(4,5)],6)                                                                         => 1296
([(1,5),(2,5),(3,4),(4,5)],6)                                                                   => 360
([(0,1),(2,5),(3,5),(4,5)],6)                                                                   => 256
([(2,5),(3,4),(3,5),(4,5)],6)                                                                   => 504
([(0,5),(1,5),(2,5),(3,4),(4,5)],6)                                                             => 374
([(1,5),(2,5),(3,4),(3,5),(4,5)],6)                                                             => 288
([(0,5),(1,5),(2,5),(3,4),(3,5),(4,5)],6)                                                       => 282
([(2,4),(2,5),(3,4),(3,5)],6)                                                                   => 1152
([(0,5),(1,5),(2,4),(3,4)],6)                                                                   => 144
([(1,5),(2,3),(2,4),(3,5),(4,5)],6)                                                             => 564
([(0,5),(1,5),(2,3),(3,4),(4,5)],6)                                                             => 166
([(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                             => 576
([(1,5),(2,4),(3,4),(3,5),(4,5)],6)                                                             => 252
([(0,5),(1,5),(2,4),(3,4),(4,5)],6)                                                             => 234
([(0,5),(1,5),(2,3),(2,4),(3,5),(4,5)],6)                                                       => 440
([(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                       => 300
([(0,5),(1,5),(2,4),(3,4),(3,5),(4,5)],6)                                                       => 162
([(0,5),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 220
([(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                                                       => 1080
([(0,5),(1,4),(2,4),(2,5),(3,4),(3,5)],6)                                                       => 316
([(0,5),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                                                 => 680
([(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 396
([(0,5),(1,4),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 192
([(0,5),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 282
([(0,4),(0,5),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                                           => 1280
([(0,4),(0,5),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 528
([(0,5),(1,4),(2,3)],6)                                                                         => 216
([(1,5),(2,4),(3,4),(3,5)],6)                                                                   => 252
([(0,1),(2,5),(3,4),(4,5)],6)                                                                   => 144
([(1,2),(3,4),(3,5),(4,5)],6)                                                                   => 288
([(0,5),(1,4),(2,3),(3,5),(4,5)],6)                                                             => 156
([(1,4),(2,3),(2,5),(3,5),(4,5)],6)                                                             => 192
([(0,1),(2,5),(3,4),(3,5),(4,5)],6)                                                             => 140
([(0,4),(1,5),(2,3),(2,5),(3,5),(4,5)],6)                                                       => 104
([(1,4),(1,5),(2,3),(2,5),(3,5),(4,5)],6)                                                       => 192
([(0,5),(1,4),(1,5),(2,3),(2,5),(3,5),(4,5)],6)                                                 => 112
([(1,4),(1,5),(2,3),(2,5),(3,4)],6)                                                             => 60
([(0,5),(1,4),(2,3),(2,4),(3,5),(4,5)],6)                                                       => 296
([(1,2),(1,5),(2,4),(3,4),(3,5),(4,5)],6)                                                       => 168
([(0,5),(1,2),(1,4),(2,3),(3,5),(4,5)],6)                                                       => 22
([(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                                                       => 264
([(0,5),(1,4),(2,3),(3,4),(3,5),(4,5)],6)                                                       => 162
([(0,5),(1,2),(1,5),(2,4),(3,4),(3,5),(4,5)],6)                                                 => 99
([(0,5),(1,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 153
([(1,4),(1,5),(2,3),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 216
([(0,5),(1,4),(1,5),(2,3),(2,5),(3,4),(3,5),(4,5)],6)                                           => 136
([(0,5),(1,4),(2,3),(2,4),(3,5)],6)                                                             => 104
([(0,1),(2,4),(2,5),(3,4),(3,5)],6)                                                             => 340
([(0,5),(1,5),(2,3),(2,4),(3,4)],6)                                                             => 108
([(0,4),(1,2),(1,3),(2,5),(3,5),(4,5)],6)                                                       => 234
([(0,4),(1,2),(1,5),(2,5),(3,4),(3,5)],6)                                                       => 74
([(0,4),(1,2),(2,5),(3,4),(3,5),(4,5)],6)                                                       => 101
([(0,1),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                       => 192
([(0,4),(1,4),(2,3),(2,5),(3,5),(4,5)],6)                                                       => 86
([(0,3),(0,4),(1,2),(1,5),(2,5),(3,5),(4,5)],6)                                                 => 76
([(0,3),(1,4),(1,5),(2,4),(2,5),(3,5),(4,5)],6)                                                 => 130
([(0,4),(1,2),(1,5),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 86
([(0,1),(0,5),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 88
([(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                       => 864
([(0,5),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                                                 => 152
([(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 468
([(0,5),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 312
([(0,1),(0,5),(1,4),(2,4),(2,5),(3,4),(3,5)],6)                                                 => 24
([(0,3),(0,5),(1,3),(1,5),(2,4),(2,5),(3,4),(4,5)],6)                                           => 84
([(0,3),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 174
([(0,5),(1,4),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                                           => 119
([(0,1),(0,5),(1,4),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 112
([(0,4),(0,5),(1,4),(1,5),(2,3),(2,5),(3,4),(3,5),(4,5)],6)                                     => 114
([(0,5),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                                           => 164
([(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 312
([(0,5),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 292
([(0,5),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 198
([(0,4),(0,5),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                                     => 200
([(0,4),(0,5),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 144
([(0,5),(1,3),(1,4),(2,3),(2,4),(3,5),(4,5)],6)                                                 => 522
([(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                                                 => 288
([(0,5),(1,3),(1,4),(2,3),(2,4),(2,5),(3,5),(4,5)],6)                                           => 174
([(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,5),(4,5)],6)                                           => 384
([(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,5),(4,5)],6)                                     => 256
([(0,4),(0,5),(1,2),(1,3),(2,5),(3,4)],6)                                                       => 132
([(0,3),(0,5),(1,2),(1,5),(2,4),(3,4),(4,5)],6)                                                 => 362
([(0,5),(1,2),(1,4),(2,3),(3,4),(3,5),(4,5)],6)                                                 => 96
([(0,1),(0,2),(1,5),(2,4),(3,4),(3,5),(4,5)],6)                                                 => 44
([(0,5),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                                                 => 144
([(0,5),(1,3),(1,4),(2,4),(2,5),(3,4),(3,5)],6)                                                 => 75
([(0,1),(0,5),(1,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 99
([(0,4),(1,3),(1,5),(2,3),(2,4),(2,5),(3,5),(4,5)],6)                                           => 113
([(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(3,5),(4,5)],6)                                           => 58
([(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(2,5),(3,5),(4,5)],6)                                     => 82
([(0,4),(0,5),(1,2),(1,3),(2,4),(2,5),(3,4),(3,5)],6)                                           => 768
([(0,5),(1,2),(1,3),(1,4),(2,3),(2,4),(3,5),(4,5)],6)                                           => 144
([(0,4),(0,5),(1,2),(1,3),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                                     => 120
([(0,4),(0,5),(1,2),(1,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 180
([(0,4),(0,5),(1,2),(1,3),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 168
([(0,5),(1,2),(1,3),(1,4),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 220
([(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 360
([(0,5),(1,3),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 194
([(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 244
([(0,4),(0,5),(1,2),(1,4),(2,3),(2,5),(3,4),(3,5),(4,5)],6)                                     => 117
([(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                                     => 84
([(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 130
([(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                         => 168
([(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                               => 232
([(0,4),(0,5),(1,2),(1,3),(2,3),(4,5)],6)                                                       => 144
([(0,2),(1,4),(1,5),(2,3),(3,4),(3,5),(4,5)],6)                                                 => 120
([(0,1),(0,5),(1,5),(2,3),(2,4),(3,4),(4,5)],6)                                                 => 56
([(0,1),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                                 => 336
([(0,1),(0,5),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                                           => 72
([(0,1),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                           => 246
([(0,1),(0,5),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 156
([(0,4),(0,5),(1,2),(1,3),(2,3),(2,5),(3,4),(4,5)],6)                                           => 40
([(0,4),(0,5),(1,2),(1,3),(1,4),(2,3),(2,5),(3,5),(4,5)],6)                                     => 70
([(0,3),(1,2),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 180
([(0,3),(0,5),(1,2),(1,4),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 74
([(0,1),(0,5),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                                     => 196
([(0,3),(0,5),(1,2),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 110
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)],6)                               => 128
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                         => 112
([(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(2,5),(3,4)],6)                                           => 52
([(0,1),(0,5),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                                           => 52
([(0,3),(0,4),(1,2),(1,4),(1,5),(2,3),(2,5),(3,5),(4,5)],6)                                     => 50
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,3),(2,5),(3,5),(4,5)],6)                               => 10
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,3),(2,5),(3,4)],6)                                     => 36
([(0,1),(0,3),(0,5),(1,2),(1,4),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 70
([(0,4),(0,5),(1,2),(1,3),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                               => 124
([(0,1),(0,4),(0,5),(1,3),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                         => 90
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                   => 124
([(0,2),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(3,4),(3,5),(4,5)],6)                               => 152
([(0,4),(0,5),(1,2),(1,3),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                         => 150
([(0,5),(1,2),(1,3),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 228
([(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                               => 720
([(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6)                         => 504
([(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)                   => 372
([(0,3),(0,4),(0,5),(1,2),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                         => 176
([(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5)],6)                         => 240
([(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)                   => 384
([(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,4),(2,5),(3,4),(3,5),(4,5)],6)             => 208
([(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)       => 288
([(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) => 720

-----------------------------------------------------------------------------
Created: Jun 06, 2022 at 18:38 by Martin Rubey

-----------------------------------------------------------------------------
Last Updated: Jun 06, 2022 at 18:38 by Martin Rubey