# Determining Complete Bipartite Graphs 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 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

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!