Behavior of purge

Dear all, I do not understand the behavior of the following code (this is
not a minimal example, I tried to reproduce the problem on a minimal
example but I could not...). I do not get why, when I purge the vertices
and edges after filtering, the properties of the vertices are not
consistent.
Thanks for your help,
Flavien.

_graph = gt.Graph(_originalGraph)

_bus = _graph.new_vertex_property('bool')
_bus.a = True
_trainVertices = [_v for _v in _graph.vertices() if _name[_v][:3] == 'stn']

for _v in _trainVertices :
    _bus[_v] = False

print 'original graph #', _graph
print 'train number # ', len([_v for _v in _graph.vertices() if
_name[_v][:3] == 'stn']), '\n'

_graph.set_vertex_filter(_bus)
print 'filtered graph #', _graph
print 'train number #', len([_v for _v in _graph.vertices() if
_name[_v][:3] == 'stn']), '\n'

_graph.purge_vertices()
_graph.purge_edges()
print 'purged graph #', _graph
print 'train number #', len([_v for _v in _graph.vertices() if
_name[_v][:3] == 'stn']), '\n'

original graph # <Graph object, directed, with 2775 vertices and 9341
edges at 0x313be50>

attachment.html (2.44 KB)

I cannot investigate further if I cannot reproduce the problem myself.
Can't you just save the graph and the properties, together with the code
you sent, so that it can be debugged?

Best,
Tiago

*Hi everyone, I come back with my problem with purge but on a different
perspective. It seems that there is really a weird thing going on (or I
missed something which is highly possible).*
*The code is the following :*

_graph.vertex_properties["_graphml_vertex_id"] = _name

_graph.vertex_properties["location"] = _position

_graph.edge_properties["_graphml_edge_id"] = _edgeName

_graph.edge_properties["speed"] = _speed

_graph.edge_properties["time"] = _time

_graph.edge_properties["capacity"] = _capacity

_graph.edge_properties["vehicles"] = _vehicles

_graph

Out[27]:

<Graph object, directed, with 2622 vertices and 8765 edges at 0x1443a3d0>

*Starting from this graph, I extract the strongly connected component*

_sccFiltered = gt.GraphView(_graph, vfilt =
topo.label_largest_component(_graph))

_scc = gt.Graph(_sccFiltered)

_scc.purge_vertices()

_scc.purge_edges()

_scc

Out[28]:

<Graph object, directed, with 2554 vertices and 8689 edges, edges filtered by
(<PropertyMap object with key type 'Edge' and value type 'bool',
for Graph 0x144417d0, at 0x14457450>, False), vertices filtered by
(<PropertyMap object with key type 'Vertex' and value type 'bool', for
Graph 0x144417d0, at 0x1442abd0>, False) at 0x144417d0>

*Now if I save the graph with*

_scc.save('network-busesAndTrains.xml.gz')

*the saved graph is all screwed up. The property maps do not correspond to
the right vertices. But if I do before saving*

_scc.vertex_properties['origin'] = _origin
_scc.vertex_properties['destination'] = _destination
_scc.vertex_properties["_graphml_vertex_id"] = _name
_scc.vertex_properties["location"] = _position
_scc.edge_properties["_graphml_edge_id"] = _edgeName
_scc.edge_properties["speed"] = _speed
_scc.edge_properties["time"] = _time
_scc.edge_properties["capacity"] = _capacity
_scc.edge_properties["vehicles"] = _vehicles

*then everything is all right (all the properties must be included).*

*I will save the two networks tomorrow for you to check, I just mentioned
the behaviour now when it is fresh in my mind.*

*All the best,*
*F.*

attachment.html (5.47 KB)