Hi all,
I found something weird in deleting vertices and edges of a graph. Say I
simply create a graph like:
g = Graph(directed=False)
g.add_vertex(7)
g.add_edge(g.vertex(0), g.vertex(1))
g.add_edge(g.vertex(1), g.vertex(2))
g.add_edge(g.vertex(2), g.vertex(3))
g.add_edge(g.vertex(3), g.vertex(4))
g.add_edge(g.vertex(2), g.vertex(5))
g.add_edge(g.vertex(5), g.vertex(6))
del_list = [g.vertex(1), g.vertex(3)]
for v in reversed(sorted(del_list)):
print 'deleting vertex', int(v)
## for ve in v.out_edges():
## print 'deleting edges', ve.source(), ve.target()
## g.remove_edge(ve)
g.remove_vertex(v, fast=True)
The above code will delete vertex 3 first, then vertex 1 as expected.
However, in order to keep correct topology, we should delete some related
edges first, like the three commented lines (start with "##").
But if you uncomment the three lines, weird thing happens: the program
will delete vertex 1 first, then vertex 3.
Of course I can sort the vertex index instead of vertex descriptor to avoid
the problem. But I am wondering where is wrong. Could anyone explain this?
--
Cheers,
Bo Wu
_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool