Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#746 closed defect (fixed)

[with patch] graphs: graph name is not reset using clear()

Reported by: Jason Grout Owned by: William Stein
Priority: major Milestone: sage-2.8.6
Component: combinatorics Keywords: graphs
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Since networkX uses the empty string for an unset name, while the current SAGE code uses None for an unset name, calling _nxg.clear() in the clear() function will not reset the name to None, but to .

There are also other problems with having an unset name represented by None (mostly because networkX assumes that is an unset name).

Change History (6)

comment:1 Changed 15 years ago by Jason Grout

Milestone: sage-2.9sage-2.8.6
Summary: graphs: graph name is not reset using clear()[patch] graphs: graph name is not reset using clear()

--- a/sage/graphs/graph.py Wed Sep 26 09:37:18 2007 -0700 +++ b/sage/graphs/graph.py Fri Sep 28 13:45:19 2007 -0500 @@ -684,10 +684,34 @@ class GenericGraph?(SageObject?):

def clear(self):

"""

  • Empties the graph of vertices and edges, removes name.

+ Empties the graph of vertices and edges and removes name, + boundary, associated objects, and position information. + + EXAMPLE: + sage: G=graphs.CycleGraph?(4); G.associate({0:'vertex0'}) + sage: G.order(); G.size() + 4 + 4 + sage: len(G._pos) + 4 + sage: G.name() + 'Cycle graph' + sage: G.obj(0) + 'vertex0' + sage: G.clear() + sage: G.order(); G.size() + 0 + 0 + sage: len(G._pos) + 0 + sage: G.name() + sage: G.obj(0)

""" self._nxg.clear()

+ self._pos=[] + self._boundary=[] + self._assoc=None

def neighbors(self, vertex):

"""

comment:2 Changed 15 years ago by Jason Grout

Let's try that again:

--- a/sage/graphs/graph.py      Wed Sep 26 09:37:18 2007 -0700
+++ b/sage/graphs/graph.py      Fri Sep 28 13:46:41 2007 -0500
@@ -684,10 +684,34 @@ class GenericGraph(SageObject):

     def clear(self):
         """
-        Empties the graph of vertices and edges, removes name.
+        Empties the graph of vertices and edges and removes name,
+        boundary, associated objects, and position information.
+
+        EXAMPLE:
+            sage: G=graphs.CycleGraph(4); G.associate({0:'vertex0'})
+            sage: G.order(); G.size()
+            4
+            4
+            sage: len(G._pos)
+            4
+            sage: G.name()
+            'Cycle graph'
+            sage: G.obj(0)
+            'vertex0'
+            sage: G.clear()
+            sage: G.order(); G.size()
+            0
+            0
+            sage: len(G._pos)
+            0
+            sage: G.name()
+            sage: G.obj(0)

         """
         self._nxg.clear()
+        self._pos=[]
+        self._boundary=[]
+        self._assoc=None

     def neighbors(self, vertex):
         """

comment:3 Changed 15 years ago by Mike Hansen

Summary: [patch] graphs: graph name is not reset using clear()[with patch] graphs: graph name is not reset using clear()

comment:4 Changed 15 years ago by William Stein

Milestone: sage-2.8.6sage-2.8.7

comment:5 Changed 15 years ago by Robert Miller

Resolution: fixed
Status: newclosed

comment:6 Changed 15 years ago by Robert Miller

Milestone: sage-2.8.7sage-2.8.6
Note: See TracTickets for help on using tickets.