Opened 12 years ago
Closed 11 years ago
#9714 closed defect (fixed)
Graph(..., format='incidence_matrix') doesn't work with graphs that have loops, but G.incidence_matrix() does. So?
Reported by: | William Stein | Owned by: | jason, ncohen, rlm |
---|---|---|---|
Priority: | minor | Milestone: | sage-5.0 |
Component: | graph theory | Keywords: | |
Cc: | Merged in: | sage-5.0.beta5 | |
Authors: | Lukáš Lánský, Robert Miller | Reviewers: | Nathann Cohen |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
We have
sage: M = matrix(3, [1,2,0, 0,2,0, 0,0,1]) sage: g = Graph(M, format='adjacency_matrix') sage: I = g.incidence_matrix(); I [-1 -1 0 0 0 1] [ 1 1 0 1 1 0] [ 0 0 1 0 0 0]
But then:
sage: Graph(I, format='incidence_matrix').show(graph_border=True) kaboom!
Either the first .incidence_matrix() should fail, or the second Graph(...) should work.
Apply:
Attachments (3)
Change History (18)
comment:1 Changed 12 years ago by
Changed 11 years ago by
Attachment: | trac_9714_incidence_checking.patch added |
---|
comment:2 Changed 11 years ago by
Status: | new → needs_review |
---|
Then there is another problem: checking forgets possibility that there are only two vertices defined. I tried to fix that: see the second doctest.
comment:3 Changed 11 years ago by
Reviewers: | → Nathann Cohen |
---|
Helloooooooooooooooo !!!
I find a bit weird that this code deals with -1 and 1 entries for *undirected* graphs, but well... ^^;
Anyway, here is a very small patch that just avoid some unnecessary computations.
I give a positive review to your patch, and you can review mine if you have some time :-)
Nathann
comment:4 Changed 11 years ago by
Hi, thanks for the review. You are certainly right that -1 is weird thing in this context and constructor should accept a normal incidence matrix with two ones in each column. I'll start another ticket for this.
I'll set positive review as soon as the tests pass.
comment:6 Changed 11 years ago by
Status: | needs_review → positive_review |
---|
What do you say to this adjustment? :-)
"Stupid me"
Ok, now it's good to go :-)
Nathann
comment:7 Changed 11 years ago by
Authors: | → Lukáš Lánský |
---|
comment:8 Changed 11 years ago by
Authors: | Lukáš Lánský → Lukáš Lánský, Robert Miller |
---|
comment:12 Changed 11 years ago by
The last two patches have one annoyingly long line as commit message. Could you please shorten the line length. Multiple lines are allowed, but the first line should make sense by itself.
comment:13 Changed 11 years ago by
Status: | positive_review → needs_work |
---|
Changed 11 years ago by
Attachment: | trac_9714_review.patch added |
---|
Changed 11 years ago by
Attachment: | trac_9714_review_review.patch added |
---|
comment:15 Changed 11 years ago by
Merged in: | → sage-5.0.beta5 |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
Easy to fix, just replace (on line 944 of
graph.py
)with something like