#29276 closed enhancement (duplicate)

DiGraph constructor should be able to handle incidence matrix with all zero entries in column

Reported by: gh-vipul79321 Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: graph theory Keywords:
Cc: dcoudert Merged in:
Authors: Vipul Gupta Reviewers: David Coudert
Report Upstream: N/A Work issues:
Branch: u/gh-vipul79321/ticket29276 (Commits, GitHub, GitLab) Commit: 841e15a04705c3123098dcd088ba3f86f5d2f732
Dependencies: Stopgaps:

Status badges

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 gh-vipul79321

  • Branch set to u/gh-vipul79321/ticket29276
  • Commit set to 2f19d192a5694b996b99150982e148c5200ae33b
  • Status changed from new to needs_review

New commits:

2f19d19Fixed ticket 29276

comment:2 follow-up: Changed 14 months ago by dcoudert

  • the test should be if not NZ:
  • add a TESTS: block like
    TESTS:
    
    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 git

  • Commit changed from 2f19d192a5694b996b99150982e148c5200ae33b to 6b96063f2eb319e13b188916934a9f4d726ab700

Branch pushed to git repo; I updated commit sha1. New commits:

6b96063Test added

comment:4 in reply to: ↑ 2 Changed 14 months ago by gh-vipul79321

Replying to dcoudert:

  • the test should be if not NZ:
  • add a TESTS: block like
    TESTS:
    
    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 follow-up: Changed 14 months ago by dcoudert

the changes done for #29275 also apply here to slightly speed up the code.

comment:6 Changed 14 months ago by git

  • Commit changed from 6b96063f2eb319e13b188916934a9f4d726ab700 to e30516b99e795714f4e6db385ced0188bee79ad3

Branch pushed to git repo; I updated commit sha1. New commits:

e30516bTests added

comment:7 Changed 14 months ago by git

  • Commit changed from e30516b99e795714f4e6db385ced0188bee79ad3 to b7c2de137c97230ff4c0287ac138919c2fc16c34

Branch pushed to git repo; I updated commit sha1. New commits:

b7c2de1Tests added for ticket 29276 and 29275

comment:8 Changed 14 months ago by git

  • Commit changed from b7c2de137c97230ff4c0287ac138919c2fc16c34 to 841e15a04705c3123098dcd088ba3f86f5d2f732

Branch pushed to git repo; I updated commit sha1. New commits:

841e15atypos fixed

comment:9 in reply to: ↑ 5 Changed 14 months ago by gh-vipul79321

Replying to dcoudert:

the changes done for #29275 also apply here to slightly speed up the code.

Done

comment:10 follow-up: Changed 14 months ago by dcoudert

  • Reviewers set to David Coudert

If I'm not mistaken, this ticket do exactly the same as #29275. If so, we can set this one as duplicate of #29275.

Don't forget to add your name in Authors field.

comment:11 in reply to: ↑ 10 Changed 14 months ago by gh-vipul79321

  • Authors set to Vipul Gupta
Last edited 14 months ago by gh-vipul79321 (previous) (diff)

comment:12 Changed 14 months ago by dcoudert

  • Milestone changed from sage-9.1 to sage-duplicate/invalid/wontfix
  • Status changed from needs_review to positive_review

all issues fixed in #29275.

comment:13 Changed 13 months ago by chapoton

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.