Hi, I'm using the function add_edge_list() to add vertices/edges to the graph. However, I have to do the operation more than once and I was wondering if there was a way of updating property maps. For example: g = Graph() edges = [(0, 1), (4, 6), (1, 2)] vertex_map = g.add_edge_list(edges, hashed=True) g.vp["vertex_map"] = vertex_map print([(g.vertex_index[v], g.vp["vertex_map"][v]) for v in g.vertices()]) # [(0, 0), (1, 1), (2, 4), (3, 6), (4, 2)] edges = [(1, 6), (7, 8)] vertex_map = g.add_edge_list(edges, hashed=True) print([(g.vertex_index[v], vertex_map[v]) for v in g.vertices()])
-- Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
Am 20.11.19 um 12:48 schrieb danoli:
Hi, I'm using the function |add_edge_list()| to add vertices/edges to the graph. However, I have to do the operation more than once and I was wondering if there was a way of updating property maps. For example:
|g = Graph() edges = [(0, 1), (4, 6), (1, 2)] vertex_map = g.add_edge_list(edges, hashed=True) g.vp["vertex_map"] = vertex_map print([(g.vertex_index[v], g.vp["vertex_map"][v]) for v in g.vertices()])| |# [(0, 0), (1, 1), (2, 4), (3, 6), (4, 2)]| |edges = [(1, 6), (7, 8)] vertex_map = g.add_edge_list(edges, hashed=True) print([(g.vertex_index[v], vertex_map[v]) for v in g.vertices()])|
No, there is currently no way of doing this with multiple calls. You would need to concatenate the edge lists if you want to use "hashed=True".
But that would be easy to implement... Please open an issue in the website, so I can add it when time permits.
Best, Tiago