On Fri, Feb 26, 2010 at 9:05 AM, Ryan Hinton <iob...@email.com> wrote:
...
> OK, assume we solve (1) by requiring an indication of which partition
> a vertex belongs in and raising an exception otherwise.  What about
> Graph algorithms that change the graph temporarily or just don't "do
> the right thing" for BipartiteGraph's?  I see a few possibilities.

I would strongly suggest this approach, i.e. option (C). As it
currently stands, a BipartiteGraph is essentially a Graph, together
with a bipartition and a few specialized functions. When you add a
vertex to this kind of object, it only stays this kind of object if
you specify which cell of the partition the vertex should go in. If
you don't specify, it should raise an error. Otherwise a Bipartite
Graph becomes something much more spooky and complicated, with "limbo"
vertices etc. Imagine a graph theorist who didn't know internals
trying to make sense of what was going on!

Then for Graph algorithms that don't do the right thing for
BipartiteGraphs, just override them all. If you don't feel like
rewriting all of them, raise NotImplemented errors. Anything in Graphs
that depend on BG's that don't do this properly will loudly and
clearly raise errors and then they can get fixed.

Any of the other approaches listed here seem prone to introduce a lot
of bugs and suck up a lot of developer time, both now and later.

> C.  Continue as we do now, i.e. BipartiteGraph is a subclass of Graph
> and overrides methods when necessary.  This requires a thorough review
> of the current Graph code to see where bipartite-ness must be taken
> into account or can be exploited (optional).

Back when #1941 was created, this thorough review was done. It may
need to be updated.

> PRO: clean separation; perhaps a little less work initially.  CON:
> future Graph methods most likely to break for BipartiteGraph
> instances; some duplication of code possible for similar but distinct
> BipartiteGraph algorithms.

I want to say that the majority of algorithms will be untouched by
this approach, and that using Python's advanced class-handling
capabilities will minimize code duplication.

-- 
Robert L. Miller
http://www.rlmiller.org/

-- 
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