Determining Complete Bipartite Graphs

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 close merge delete

Sort by ยป oldest newest most voted

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.

more

Thanks for the help! I got what I wanted.

( 2011-09-01 11:03:53 -0500 )edit

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)

more

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!

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