First time here? Check out the FAQ!

Ask Your Question
0

How to get only the connected graphs from this code

asked 6 years ago

anonymous user

Anonymous

how to get only the connected graphs from this code.

for G in graphs(10):

G.show()

L=G.laplacian_matrix().eigenvalues()

L.sort()

show(L)

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

rburing gravatar image

You can replace graphs(10) by

filter(lambda g: g.is_connected(), graphs(10))

It is more efficient to use the nauty backend; replace graphs(10) by

graphs.nauty_geng('10 -c')
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 127 times

Last updated: Feb 12 '19