[graph-tool-tickets] [graph-tool] Ticket #108: g.reindex_edges() needs to take into account the edges property maps

graph-tool webmaster at skewed.de
Fri Jul 20 08:42:21 UTC 2012


#108: g.reindex_edges() needs to take into account the edges property maps
new enhancement
---------------------------------------------------------------------
Reporter: oleguer.sagarra at gmail.com
Owner: Oleguer
Priority: normal
Milestone: (None)
---------------------------------------------------------------------
When reindexing the edges on a graph (for instance, upon deleting edges (self loops for instance) the function should also take care to preserve the mapping with the edge_property maps. I don't know whether this is a bug (unintentional) or an improvement (a flag could be passed to the function in order to do so).

See example below:

In [66]: g=gt.Graph()

In [67]: g.add_vertex(2)

Out[67]: 
[<Vertex object with index '0' at 0x406c1d0>,
 <Vertex object with index '1' at 0x406c250>]

In [68]: g.add_edge(g.vertex(0),g.vertex(1))

Out[68]: <Edge object with source '0' and target '1' at 0x4066dd0>

In [69]: g.add_edge(g.vertex(1),g.vertex(0))

Out[69]: <Edge object with source '1' and target '0' at 0x4066f80>

In [70]: z=g.new_edge_property("int")

In [71]: z[g.edge(0,1)]=84

In [72]: z[g.edge(1,0)]=-84

In [73]: f= lambda x: z[x]==84 # to remove edges afterwards

In [74]: g.edge_properties["z"]=z

In [75]: for e in g.edges():
   ....:     print g.edge_properties['z'][e]
   ....:     
84
-84

In [77]: g.remove_edge_if(f) # remove edge

In [78]: for e in g.edges(): # this is ok
    print g.edge_properties["z"][e]
   ....:     
-84

In [79]: g.reindex_edges() #reindex

In [80]: for e in g.edges(): # this is NOT ok.
    print g.edge_properties["z"][e]
   ....:     
84





--
Ticket URL: <URL:http://graph-tool.skewed.de/ticket/108>
graph-tool <URL:http://graph-tool.skewed.de/>
An efficient python module for graph analysis and manipulation.


More information about the graph-tool-tickets mailing list