Opened 10 years ago

Last modified 5 years ago

#12540 new defect

Graph library passes almost surelly erroneous calls without an exception

Reported by: brunellus Owned by: jason, ncohen, rlm
Priority: major Milestone: sage-6.4
Component: graph theory Keywords:
Cc: vbraun, ncohen Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


  1. Dense backend doesn't support edge labels, but add_edge(1, 2, 3) passes and behaves like add_edge(1, 2, None). (#12387)
  2. Adding a loop to a graph with allows_loops=False do nothing.
  3. Adding an already present edge to a graph with allows_multiedges=False do nothing.
  4. (Other?)

Is this the proper behavior?

Change History (5)

comment:1 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:2 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 5 years ago by pelegm

No answer here, so I ask explicitly again about (2).

In SparseGraphBackend, for example, the following lines appear in the add_edge method:

        if (not self.loops(None)) and u_int == v_int:

This means that if the backend does not allow loops, the add_edge method silently ignore the added edge. By default, SparseGraphBackend does not allow loops.

Is this a wanted behaviour?

If not, there are couple of ways to handle this:

  1. raise from inside the backend method
  2. warn (somehow) from inside the backend method
  3. let the backend return False (or whatever) in case the edge was not added, and let the graph itself notice it and raise/warn
Note: See TracTickets for help on using tickets.