Ask Your Question
1

Determining Complete Bipartite Graphs

asked 2011-08-30 04:56:35 -0500

anonymous user

Anonymous

I have generated an extremely large list of graphs. Do you know if there is a way to determine which graphs in the list are Complete Bipartite graphs? I have tried a filter function: dd = filter(lambda x:x.completebipatitegraphs(), d), but it gives me an "attribute needed" error. Any help is greatly appreciated!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2011-08-31 06:14:31 -0500

Mike Hansen gravatar image

You can use the following function to test if a graph is complete bipartite:

def is_complete_bipartite(p):
    return p.is_bipartite() and p.num_edges() == mul(map(len, p.bipartite_sets()))

Then, you can do

dd = filter(is_complete_bipartite, d)

to get your list of complete bipartites.

edit flag offensive delete link more

Comments

Thanks for the help! I got what I wanted.

acacost1 gravatar imageacacost1 ( 2011-09-01 11:03:53 -0500 )edit
1

answered 2011-09-04 01:16:48 -0500

in case you want to practice writing lambdas, you can do

dd=filter(lambda p: p.is_bipartite() and p.num_edges() == mul(map(len, p.bipartite_sets())), d)
edit flag offensive delete link more

Comments

I have been reading the Sage References, and it does not seem that complete multipartite graphs are defined in Sage yet. I have tried to critique the code you have provide to try and see if it would work for complete multipartite graphs. I get a "graph attribute needed" error. I just wanted to verify that this is the case. Thanks again for the help!

acacost1 gravatar imageacacost1 ( 2011-09-06 18:08:51 -0500 )edit

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: 2011-08-30 04:56:35 -0500

Seen: 241 times

Last updated: Sep 04 '11