Opened 14 months ago
Closed 13 months ago
#29276 closed enhancement (duplicate)
DiGraph constructor should be able to handle incidence matrix with all zero entries in column
Reported by:  ghvipul79321  Owned by:  

Priority:  major  Milestone:  sageduplicate/invalid/wontfix 
Component:  graph theory  Keywords:  
Cc:  dcoudert  Merged in:  
Authors:  Vipul Gupta  Reviewers:  David Coudert 
Report Upstream:  N/A  Work issues:  
Branch:  u/ghvipul79321/ticket29276 (Commits, GitHub, GitLab)  Commit:  841e15a04705c3123098dcd088ba3f86f5d2f732 
Dependencies:  Stopgaps: 
Description
Currently DiGraph? constructor works in following manner
sage: m=Matrix([[0,1],[0,1],[0,0]]) sage: G = DiGraph(m,format='incidence_matrix') Traceback (most recent call last) ... ValueError: there must be two nonzero entries (1 & 1) per column
It should be able to handle incidence matrix containing column with all zero entries by dropping that column and returning a Digraph which will be loop less version of that incidence matrix
Change History (13)
comment:1 Changed 14 months ago by
 Branch set to u/ghvipul79321/ticket29276
 Commit set to 2f19d192a5694b996b99150982e148c5200ae33b
 Status changed from new to needs_review
comment:2 followup: ↓ 4 Changed 14 months ago by
 the test should be
if not NZ:
 add a
TESTS:
block likeTESTS: Handle incidence matrix containing a column with only zeros (:trac:`29276`):: sage: m = Matrix([[0,1],[0,1],[0,0]]) sage: m [ 0 1] [ 0 1] [ 0 0] sage: G = DiGraph(m,format='incidence_matrix') sage: list(G.edges(labels=False)) [(1, 0)]
comment:3 Changed 14 months ago by
 Commit changed from 2f19d192a5694b996b99150982e148c5200ae33b to 6b96063f2eb319e13b188916934a9f4d726ab700
Branch pushed to git repo; I updated commit sha1. New commits:
6b96063  Test added

comment:4 in reply to: ↑ 2 Changed 14 months ago by
Replying to dcoudert:
 the test should be
if not NZ:
 add a
TESTS:
block likeTESTS: Handle incidence matrix containing a column with only zeros (:trac:`29276`):: sage: m = Matrix([[0,1],[0,1],[0,0]]) sage: m [ 0 1] [ 0 1] [ 0 0] sage: G = DiGraph(m,format='incidence_matrix') sage: list(G.edges(labels=False)) [(1, 0)]
Done
comment:5 followup: ↓ 9 Changed 14 months ago by
the changes done for #29275 also apply here to slightly speed up the code.
comment:6 Changed 14 months ago by
 Commit changed from 6b96063f2eb319e13b188916934a9f4d726ab700 to e30516b99e795714f4e6db385ced0188bee79ad3
Branch pushed to git repo; I updated commit sha1. New commits:
e30516b  Tests added

comment:7 Changed 14 months ago by
 Commit changed from e30516b99e795714f4e6db385ced0188bee79ad3 to b7c2de137c97230ff4c0287ac138919c2fc16c34
Branch pushed to git repo; I updated commit sha1. New commits:
b7c2de1  Tests added for ticket 29276 and 29275

comment:8 Changed 14 months ago by
 Commit changed from b7c2de137c97230ff4c0287ac138919c2fc16c34 to 841e15a04705c3123098dcd088ba3f86f5d2f732
Branch pushed to git repo; I updated commit sha1. New commits:
841e15a  typos fixed

comment:9 in reply to: ↑ 5 Changed 14 months ago by
comment:10 followup: ↓ 11 Changed 14 months ago by
 Reviewers set to David Coudert
comment:11 in reply to: ↑ 10 Changed 14 months ago by
comment:12 Changed 14 months ago by
 Milestone changed from sage9.1 to sageduplicate/invalid/wontfix
 Status changed from needs_review to positive_review
all issues fixed in #29275.
comment:13 Changed 13 months ago by
 Resolution set to duplicate
 Status changed from positive_review to closed
New commits:
Fixed ticket 29276