Hello Everybody

I was working on a function is_perfect, which tests whether a given graph is
perfect. This function has the bad idea to compute the complement of a
graph.

Writing the docstrings, I wrote that Bipartite Graphs are obviously perfect,
which is perfectly true.

Here is what happens in Sage :

sage: g =
graphs.RandomBipartite(8,4,.5)

sage: g.is_perfect()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/home/ncohen/<ipython console> in <module>()

/home/ncohen/.Sage/local/lib/python2.6/site-packages/sage/graphs/graph.pyc
in is_perfect(self, certificate)
   1443         """
   1444
-> 1445         self_complement = self.complement()
   1446
   1447         start_complement = self_complement.girth()

/home/ncohen/.Sage/local/lib/python2.6/site-packages/sage/graphs/generic_graph.pyc
in complement(self)
   8497             for v in self:
   8498                 if not self.has_edge(u,v):
-> 8499                     G.add_edge(u,v)
   8500         return G
   8501

/home/ncohen/.Sage/local/lib/python2.6/site-packages/sage/graphs/bipartite_graph.pyc
in add_edge(self, u, v, label)
    690         # check for endpoints in different partitions
    691         if self.left.issuperset((u,v)) or
self.right.issuperset((u,v)):
--> 692             raise RuntimeError('Edge vertices must lie in different
partitions.')
    693
    694         # add the edge

RuntimeError: Edge vertices must lie in different partitions.

This comes from that fact that BipartiteGraphs are not graphs like others,
that some functions are forbidden, others are modified to prevent the graph
from becoming non-biapartite, etc, etc... I know all this. Meanwhile, I do
not like to see such a code fail for this reason.

As there are people around working on this BipartiteGraph class : what would
you think of having the constructors returning regular graphs instead of
these constrained versions of it ? This way, the users will only use this
class if they means to, and not have several functions (and even code that
should - not - be uncompatible ) disabled by default because of the
constructor ? If you have any other ideas, they are welcome !

Nathann

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to