Ask Your Question

acacost1's profile - activity

2023-08-22 04:37:39 +0100 received badge  Famous Question (source)
2022-01-24 19:31:44 +0100 received badge  Notable Question (source)
2017-08-04 12:34:11 +0100 received badge  Famous Question (source)
2014-06-26 16:36:29 +0100 received badge  Notable Question (source)
2014-02-01 17:33:54 +0100 received badge  Taxonomist
2013-12-08 13:26:41 +0100 received badge  Popular Question (source)
2013-10-08 22:18:17 +0100 received badge  Popular Question (source)
2012-10-16 11:42:44 +0100 received badge  Nice Question (source)
2011-09-20 20:45:56 +0100 marked best answer Determining Complete Multipartite Graphs (Specifically Tripartite)

You're getting that error because there is no is_multipartite method on graphs in Sage, nor is there a multipartite_sets method. You can use the coloring method to get what you need since a tripartite graph is 3-colourable. Thus, you could do something like the following: (To simplify things, I'll just consider the m > 1 case.)

def is_complete_multipartite(m):
    assert m > 1
    def is_complete_m_partite(g):
        coloring = g.coloring()
        if coloring is None: #empty graph
            return False
        return len(coloring) == m and g.num_edges() == mul(map(len, coloring))
    return is_complete_m_partite

Then, you'd use it like

dd = filter(is_complete_multipartite(3), d)

to test for complete tripartiteness.

2011-09-15 16:28:43 +0100 commented answer Determining Complete Multipartite Graphs (Specifically Tripartite)

Thanks! I'll give it try.

2011-09-14 17:41:08 +0100 asked a question Determining Complete Multipartite Graphs (Specifically Tripartite)

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 following two lines of code to see if it would work for complete multipartite graphs.

def is_complete_multipartite(p):
    return p.is_multipartite() and p.num_edges() == mul(map(len, g.multipartite_sets()))

dd = filter(is_complete_multipartite, d)

I get a "graph attribute needed" error. I just wanted to verify that this is the case. Thanks again for the help!

2011-09-07 01:08:51 +0100 commented answer Determining Complete Bipartite Graphs

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-01 18:03:53 +0100 commented answer Determining Complete Bipartite Graphs

Thanks for the help! I got what I wanted.

2011-09-01 18:02:49 +0100 marked best answer Determining Complete Bipartite Graphs

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.

2011-09-01 18:02:49 +0100 received badge  Scholar (source)
2011-09-01 18:02:46 +0100 received badge  Supporter (source)
2011-09-01 14:14:46 +0100 received badge  Student (source)
2011-08-30 11:56:35 +0100 asked a question 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!