On 03/06/2010 02:30 AM, Minh Nguyen wrote:
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.
Wow, that seems really, really bad. Shouldn't a generator like graphs()
return *copies* of the graphs it is using internally? The extremely
common use-case:
for g in graphs(3):
do something to g, add it to a list, etc.
could potentially really mess up things, then! For example, what if I
delete a vertex? I get a big list index error for the following code:
for g in graphs(3):
g.delete_vertex(0)
print g.am()
Robert, do you agree that this should be changed to return a copy of the
graph, instead of the actual graph used to build other graphs?
Thanks,
Jason
--
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