#5171: Bugs in the Graph constructor when input an adjacency matrix.
--------------------------+-------------------------------------------------
 Reporter:  was           |       Owner:  rlm     
     Type:  defect        |      Status:  new     
 Priority:  critical      |   Milestone:  sage-3.3
Component:  graph theory  |    Keywords:          
--------------------------+-------------------------------------------------
 1. The adjacency matrix of a graph constructed from an adjacency matrix
 should either be the same or one should get an error when constructing the
 graph:
 {{{
 sage: a = matrix(2,2,[1,0,0,1])
 sage: Graph(a)
 Graph on 2 vertices
 sage: Graph(a).adjacency_matrix()  # I think Graph(a) should work or given
 an error
 [0 0]
 [0 0]
 sage: Graph(a, loops=True).adjacency_matrix()
 [1 0]
 [0 1]
 }}}

 Another example -- this is WRONG, since multiple loops should not be
 ignored.
 {{{
 sage: a = matrix(2,2,[2,0,0,1])
 sage: Graph(a,loops=True).adjacency_matrix()
 [1 0]
 [0 1]
 }}}

 Why not just make a graph with loops and multiple edges (or at least
 weighted edges) if and only if the adjacency matrix has diagonal entries
 or non-1 entries?  I'm guessing the Graph constructor just grew from a
 time when these constructions weren't allowed or that networkx is just
 poorly designed.  Either way, this needs to be fixed for Sage.

 2. When the input matrix is non-square, the error message is wrong in
 multiple ways:
 {{{
 sage: a = matrix([1,0,0,1])
 sage: Graph(a)
 Traceback (most recent call last):
 ...
 AttributeError: Incidence Matrix must have one 1 and one -1 per column.
 }}}

   * it should be "adjacency matrix".

   * The exception should be ValueError, not AttributeError

   * The Graph constructor doesn't take only 1's or -1's as input (but see
 above)

   * The Graph constructor is perfectly fine with having multiple 1's per
 column!

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5171>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to