Graphs on 7 vertices

42 days ago by jason3

To generate the graphs on 7 vertices, just use the graphs() command (this will take a few seconds).

graphs7=list(graphs(7)) 
       
len(graphs7) 
       
1044

To get all connected graphs, you can just construct that list from the list you just generated.

connectedgraphs7=[g for g in graphs7 if g.is_connected()] 
       

To get pictures of the first 10, just plot the graphs.

show(connectedgraphs7[:10]) 
       

Now let's get the adjacency matrix of the 200th connected graph (the numbering in the list of connectedgraphs7 starts at zero, so we ask for position 199).

G=connectedgraphs7[199] 
       
show(G) 
       
M=G.adjacency_matrix() M 
       
[0 1 1 1 0 1 1]
[1 0 1 1 0 0 0]
[1 1 0 1 0 0 0]
[1 1 1 0 1 0 0]
[0 0 0 1 0 1 1]
[1 0 0 0 1 0 1]
[1 0 0 0 1 1 0]

Then we can do some things with the matrices.

M.rank() 
       
7

Now let's explore a centrality measure.

G.centrality_betweenness() 
       
{0: 0.33333333333333331, 1: 0.0, 2: 0.0, 3: 0.15555555555555553, 4:
0.066666666666666666, 5: 0.02222222222222222, 6:
0.02222222222222222}