First time here? Check out the FAQ!

Ask Your Question
1

Determining Complete Bipartite Graphs

asked 13 years ago

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!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
3

answered 13 years ago

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.

Preview: (hide)
link

Comments

Thanks for the help! I got what I wanted.

acacost1 gravatar imageacacost1 ( 13 years ago )
1

answered 13 years ago

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)
Preview: (hide)
link

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 ( 13 years ago )

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: 13 years ago

Seen: 739 times

Last updated: Sep 04 '11