> G=Graph()
> for i in range(0,10): G.add_vertex(randint(1,1000))
> for x in G.vertex_iterator(): print x
> G.vertices()
>
> gives them in about random order.
Nope. The order is not random. It is the one you get by doing list(set(X)).
sage: list(set(G.vertices())) == list(G.vertex_iterator())
True
You can have a look at how is coded vertex_iterator in the backend
(i.e. G._backend.iterator_verts).
> I started thinking this when doing http://trac.sagemath.org/ticket/17173 .
> Nathann suggested using directly (sub)graphs instead of (sub)poset. It is
> OK with .vertices() but not with .vertex_iterator(); try
>
> G=Graph()
> for i in range(2,50): G.add_vertex(i)
> for i in range(2,50):
> if not is_prime(i):
> G.delete_vertex(i)
> for x in G.vertex_iterator(): print x
>
> This seems to be quite open door for nasty bugs. .vertex_iterator might
> give vertices in order when graph is small or has not been modified many
> times.
The code is not very clean, but nevertheless the order of
.vertex_iterator does not depend on the way you built your graph. Do
you have an example where it is not the case ?
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.