#18067: sage/graphs/graph.py: multigraph recognition in init fails
------------------------------------------+------------------------
       Reporter:  darij                   |        Owner:
           Type:  defect                  |       Status:  new
       Priority:  major                   |    Milestone:  sage-6.6
      Component:  graph theory            |   Resolution:
       Keywords:  graphs, sage-combinat,  |    Merged in:
        Authors:                          |    Reviewers:
Report Upstream:  N/A                     |  Work issues:
         Branch:                          |       Commit:
   Dependencies:                          |     Stopgaps:
------------------------------------------+------------------------

Comment (by ncohen):

 Hello !

 I was actually thinking of this very behaviour last week, as many things
 in the (di)Graph constructors should be rewritten. A lot of time is also
 wasted because we have to detect what the user 'intends' to build, and at
 some point I thought that this could be solved by asking the user to tell
 us explicitly whether (s)he wants a simple graph or a multigraph, using
 the `multiedges=True` flag. Nowadays, I am not so sure anymore.

 In this specific case, I also believe that, as you advise, we should
 return a multigraph. But to understand better what it works this way, see
 how it works for dictionary input (note that 'list of edges' input is
 converted into dictionary input):

 {{{
 sage: Graph({1:[2],2:[1]}).edges()
 [(1, 2, None)]
 }}}

 What do you think the user wants in this case ? Is (s)he giving us a
 multigraph, or merely giving the adjacencies between the vertices in both
 directions?

 Right now, giving the adjacencies in both direction or giving them only
 once yields the same result

 {{{
 sage: Graph({1:[2],2:[1]}) == Graph({1:[2]})
 True
 }}}

 And of course, saying twice that 2 is a neighbor of 1 yields a multigraph

 {{{
 sage: Graph({1:[2,2]})
 Multi-graph on 2 vertices
 }}}

 I will fix this bug soon, by making `Graph(list_of_edges)` call `add_edge`
 immediately. The code will also be shorter. But the graph constructors
 will have to be rewritten, and standards will change. We cannot guess the
 user's intent without guessing wrong at times, and we want to avoid that.

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/18067#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to