Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#716 closed defect (fixed)

graph functions to_undirected and to_directed forget the loops and multiple edges

Reported by: jason Owned by: was
Priority: major Milestone: sage-2.8.8
Component: combinatorics Keywords: graph, graphs
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

With a directed graph g

  • g.to_directed() forgets multiedges, remembers loops
  • g.to_undirected() forgets multiedges and loops

With an undirected graph g

  • g.to_directed() forgets multiedges and loops
  • g.to_undirected() forgets multiedges, remembers loops

In each of these cases, both multiedges and loops should be remembered.

sage: g=DiGraph({0:[0,1,1,2],1:[0,1]},loops=True,multiedges=True)
sage: g.to_directed().multiple_arcs()
False
sage: g.to_directed().loops()
True
sage: g.to_undirected().multiple_edges()
False
sage: g.to_undirected().loops()
False
sage: g=Graph({0:[0,1,1,2],1:[0,1]},loops=True,multiedges=True)
sage: g.to_directed().multiple_arcs()
False
sage: g.to_directed().loops()
False
sage: g.to_undirected().multiple_edges()
False
sage: g.to_undirected().loops()
True

Attachments (6)

init_and_to_simple.hg (1.1 KB) - added by jason 12 years ago.
deep_copy.hg (6.6 KB) - added by rlm 12 years ago.
Fixes doctest failures and other strangeness
doc_changes.hg (7.4 KB) - added by jason 12 years ago.
arc_edges.hg (7.4 KB) - added by rlm 12 years ago.
change_arc_to_edge.hg (11.4 KB) - added by jason 12 years ago.
combinat-arcs2edges.patch (2.8 KB) - added by mhansen 12 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 12 years ago by jason

Apparently the copy doesn't preserve multiple edges settings.

sage: g=DiGraph({0:[0,1,1,2],1:[0,1]},loops=True,multiedges=True)
sage: g==g.copy()
False
sage: g.multiple_arcs()
True
sage: g.copy().multiple_arcs()
False

comment:2 Changed 12 years ago by jason

The real problem is that the init function tests for a superclass before a subclass. The attached patch fixes it (and also adds a to_simple function that _does_ forget multiple edges, loops, and directions on edges).

The attached patch may break some of the doctests in graph.py, though.

Changed 12 years ago by jason

Changed 12 years ago by rlm

Fixes doctest failures and other strangeness

Changed 12 years ago by jason

Changed 12 years ago by rlm

Changed 12 years ago by jason

Changed 12 years ago by mhansen

comment:3 Changed 12 years ago by rlm

  • Resolution set to worksforme
  • Status changed from new to closed

comment:4 Changed 12 years ago by jason

As a side note, the above patches which were applied also changed all "arc" functions to "edge" functions. This, of course, broke backward compatibility.

comment:5 Changed 12 years ago by mabshoff

  • Milestone changed from sage-2.9 to sage-2.8.9

I am curious if all those patches really were applied. They are over a months old, so I would assume so, but I do not understand why this ticket wasn't closed then.

Michael

comment:6 Changed 12 years ago by mabshoff

  • Resolution worksforme deleted
  • Status changed from closed to reopened

comment:7 Changed 12 years ago by mabshoff

  • Milestone changed from sage-2.8.9 to sage-2.8.8
  • Resolution set to fixed
  • Status changed from reopened to closed

comment:8 Changed 12 years ago by mabshoff

From Robert:

Michael,

Regarding ticket #716, these patches were incorporated a while ago,
and I closed the ticket last month when that happened. It looks like
the ticket has been closed, but in a future milestone, ever since...

Cheers,

Michael

Note: See TracTickets for help on using tickets.