Hi,
On Sat, Mar 6, 2010 at 6:03 PM, m_p_v_13 <[email protected]> wrote:
> set_edge_label is setting labels on intended and unintended graph
>
> I generate some graphs and set one's edge labels. When I look at the
> next genetated graph, it's edge labels have been changed.
Unless I'm mistaken, the graph generator function graphs(3) returns
three graphs: G_1 with 1 edge, G_2 with 2 edges, and G_3 with three
edges. Each graph builds upon another one, so G_2 is built using G_1,
and G_3 is built using G_2. Whatever properties that are in G_1 would
be preserved in G_2, and similarly for G_3. From your report, I gather
that you don't want graph properties of G_1 to be carried over to G_2,
and neither do you want properties of G_2 to be carried over to G_3.
For completeness, I have copied a Sage session with essentially the
same code as you posted, but used within Sage 4.3.3:
[mv...@sage mvngu]$ sage
----------------------------------------------------------------------
| Sage Version 4.3.3, Release Date: 2010-02-21 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: !more graph.py
for G in graphs(3, implementation="networkx"):
if G.is_connected():
A = G.adjacency_matrix()
print "Adjacency Matrix:"
print A
print "Edges:"
for e in G.edge_iterator(labels=True):
print e
print "Setting edge labels..."
for e in G.edge_iterator(labels=True):
G.set_edge_label(e[0], e[1], "Red")
for e in G.edge_iterator(labels=True):
print e
else:
for e in G.edge_iterator(labels=True):
print e
print "-" * 20
sage: load("graph.py")
--------------------
(0, 1, None)
--------------------
Adjacency Matrix:
[0 1 1]
[1 0 0]
[1 0 0]
Edges:
(0, 1, None)
(0, 2, None)
Setting edge labels...
(0, 1, 'Red')
(0, 2, 'Red')
--------------------
Adjacency Matrix:
[0 1 1]
[1 0 1]
[1 1 0]
Edges:
(0, 1, 'Red')
(0, 2, 'Red')
(1, 2, None)
Setting edge labels...
(0, 1, 'Red')
(0, 2, 'Red')
(1, 2, 'Red')
--------------------
--
Regards
Minh Van Nguyen
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org