Iterating over the edgelist
Asked by
Raj Kumar Pan
I have a graph say:
l = [("a", "b", 3.0), ("c", "d", 4.0), ("a", "c", 5.0)]
ids=UniqueIdGen
edgelist = [(ids[u], ids[v]) for u, v, _ in l]
weights = [w for _, _, w in l]
g=Graph(edgelist, vertex_
To iterate over the edge list and print the nodes and weights I did
inv_map = {ids[k]:k for k in ids.values()}
for i, j in g.get_edgelist():
print inv_map[i], inv_map[j], g[i,j]
Is there a way to iterate over the edgelist without creating the inverse map?
Many Thanks.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- igraph Edit question
- Assignee:
- Tamás Nepusz Edit question
- Solved by:
- Tamás Nepusz
- Solved:
- Last query:
- Last reply:
To post a message you must log in.