Thanks for the reply.  Response to your suggestions below.

On Feb 26, 1:21 pm, David Joyner <wdjoy...@gmail.com> wrote:
> ...snip...
>
> > I considered another option.  Why not just wait until an edge is added
> > to figure out whether a node is left or right?  Because all the
> > vertices should be in one set or the other at all times.  For example,
> > if I add a vertex and then iterate (before adding any edges) over the
> > left and right subsets, the new vertex would be absent!
>
> It seems you are suggesting that there should be 2 ways to
> add a vertex to a bipartite graph. Either add_vertex with a
> required parameter specifying which vertex set to add it to, or
> using add_edge? I don't see a problem off-hand.

Let me clarify my suggestion.  add_vertex could have a "limbo" set --
neither left nor right -- and nodes could be moved from "limbo" to the
appropriate set when an edge is added.  In short, we know what set a
node should be in once it has an edge, but not immediately upon adding
it.

Allowing add_edge to also create the node is interesting, but doesn't
solve the problem of what to do when add_vertex is called with
insufficient information.

> > A.  Change BipartiteGraph so that it doesn't inherit from Graph.  This
> > requires adding a bunch of code to bring the BipartiteGraph
> > functionality to par with Graph.  Also, any future methods added to
> > Graph will need to be duplicated (often simply delegated) in
> > BipartiteGraph.
>
> I personally favor this as it seems to me (and I definitely could
> be wrong) that the code will be more readable in this case.
> If every method in graph.py must test if the graph is bipartite
> or not, that makes it more difficult read and more difficult to debug, IMHO.

Yes, this is the purest approach.  On the other hand, a large fraction
of the Graph methods will work *unchanged* for BipartiteGraph
instances.  And the vast majority of those that do need changes
require only minor adjustments.  Personally, adding a little extra
code to (Generic)Graph is preferable to duplicating lots of code (and
possible bugs) in BipartiteGraph.

Thanks for your opinion!

- Ryan

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