Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac 15619: Review commit
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-king-jena committed Jan 3, 2014
1 parent c441178 commit cabc969
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/sage/graphs/base/static_sparse_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,28 @@ class StaticSparseBackend(CGraphBackend):
"""
Return a tuple used for pickling this graph.
TESTS::
TESTS:
Pickling of the static graph backend makes pickling of immutable
graphs and digraphs work::
sage: G = Graph(graphs.PetersenGraph(), immutable=True)
sage: _ = loads(dumps(G))
sage: G == loads(dumps(G))
True
sage: uc = [[2,3], [], [1], [1], [1], [3,4]]
sage: D = DiGraph(dict([[i,uc[i]] for i in range(len(uc))]), immutable=True)
sage: loads(dumps(D)) == D
True
"""
if self._directed:
from sage.graphs.digraph import DiGraph as constructor
else:
from sage.graphs.graph import Graph as constructor
G = constructor()
G.add_vertices(self.iterator_verts(None))
# In order to make things work for digraphs, we use
# iterator_out_edges and not iterator_edges.
G.add_edges(list(self.iterator_out_edges(self.iterator_verts(None),1)))
return (StaticSparseBackend, (G, self._loops, self._multiedges))

Expand Down

0 comments on commit cabc969

Please sign in to comment.