#20499: Graphs: docstring of _add_ conflicts with function
--------------------------------+--------------------------
       Reporter:  jmantysalo    |        Owner:
           Type:  defect        |       Status:  needs_info
       Priority:  major         |    Milestone:  sage-7.2
      Component:  graph theory  |   Resolution:
       Keywords:                |    Merged in:
        Authors:                |    Reviewers:
Report Upstream:  N/A           |  Work issues:
         Branch:                |       Commit:
   Dependencies:                |     Stopgaps:
--------------------------------+--------------------------

Comment (by dcoudert):

 The current implementation of the `add` method is
 {{{
         if isinstance(other_graph, GenericGraph):
             return self.disjoint_union(other_graph, labels='integers')
 }}}
 So it forces to relabel vertices as integer in `[0..n-1]`.

 At the least, we should raise an error for cases such as
 `Graph({0:[]})+'junk'`. Indeed, the other ordering raises an error
 {{{
 sage: 'junk'+Graph({0:[]})
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 <ipython-input-99-2e66a308aaff> in <module>()
 ----> 1 'junk'+Graph({Integer(0):[]})

 TypeError: cannot concatenate 'str' and 'Graph' objects
 }}}

 Now, the semantic of `+` is the disjoint union, and I believe this is the
 right choice.
 We should however ensure that the doc of `__add__`, `disjoint_union`,
 `union`, `__mul__` and may be `join`, are clear enough and without
 ambiguity for users.

 Concerning the relabel to integers part, I agree that this is often
 painful. We could propose and intermediate behavior like: relabel only if
 some vertices have same label. But again some people will complain.

 David.

--
Ticket URL: <http://trac.sagemath.org/ticket/20499#comment:2>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to