0

I created a filtered graph of the graph g and would like to use it as a new graph. As far as I know the properties are also copied, but how can I access them? If I use "weight" it would be the property map of g not sub.

weight = g.new_edge_property('float')
vfilt = g.new_vertex_property('bool')
...
old_sub = gt.GraphView(g, vfilt)
sub = gt.Graph(old_sub, directed=False, prune=True)

If the properties are not copied to sub, how can a do that. Since the new graph has not the same number of vertices, the index of the vertices has changed.

Thanks a lot

Neli
  • 532
  • 1
  • 3
  • 15

1 Answers1

1

You have to make the properties "internal" to the graph before copying:

weight = g.new_edge_property('float')
vfilt = g.new_vertex_property('bool')
...
old_sub = gt.GraphView(g, vfilt)
old_sub.ep.weight = weight   # old_sub.ep is a dictionary of internal properties
sub = gt.Graph(old_sub, directed=False, prune=True)
sub_weight = sub.ep.weight   # copy of weight
Tiago Peixoto
  • 5,149
  • 2
  • 28
  • 28