# Ticket #7733: trac_7733.patch

File trac_7733.patch, 2.5 KB (added by ncohen, 11 years ago)
• ## sage/graphs/digraph.py

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1266862582 -3600
# Node ID 63c0a8169571194db5606bcd0358fcc863071f64
# Parent  75e9e97a1e60a9acb16300d9f25b065d415019fa
Ticket #7733 : Graph(g) and DiGraph(g) did not keep the embedding

diff -r 75e9e97a1e60 -r 63c0a8169571 sage/graphs/digraph.py```
 a sage: a = matrix(2,2,[3,2,0,1]) sage: DiGraph(a,sparse=True).adjacency_matrix() == a True The positions are copied when the DiGraph is built from another DiGraph or from a Graph :: sage: g = DiGraph(graphs.PetersenGraph()) sage: h = DiGraph(g) sage: g.get_pos() == h.get_pos() True sage: g.get_pos() == graphs.PetersenGraph().get_pos() True """ from sage.all import walltime msg = '' if weighted is None: weighted = data.weighted() num_verts = data.num_verts() verts = data.vertex_iterator() if data.get_pos() is not None: pos = data.get_pos().copy() elif format == 'rule': f = data[1] if loops is None: loops = any(f(v,v) for v in data[0])
• ## sage/graphs/graph.py

`diff -r 75e9e97a1e60 -r 63c0a8169571 sage/graphs/graph.py`
 a sage: a = matrix(2,2,[2,0,0,1]) sage: Graph(a,sparse=True).adjacency_matrix() == a True The positions are copied when the graph is built from another graph :: sage: g = graphs.PetersenGraph() sage: h = Graph(g) sage: g.get_pos() == h.get_pos() True Or from a DiGraph :: sage: d = DiGraph(g) sage: h = Graph(d) sage: g.get_pos() == h.get_pos() True """ GenericGraph.__init__(self) msg = '' if weighted is None: weighted = data.weighted() num_verts = data.num_verts() verts = data.vertex_iterator() if data.get_pos() is not None: pos = data.get_pos().copy() elif format == 'rule': f = data[1] if loops is None: loops = any(f(v,v) for v in data[0])