With the Python igraph library, I have a directed graph representing a road network, with distance between each vertex (coordinates) as the weight. It is quite possible that there can be two or more edges between a vertex pair, with different weights. I need to retrieve these weights from the graph by querying the vertex IDs e.g. an example graph:
import igraph as ig
g = ig.Graph(directed=True)
g.add_vertices(4)
edges = [(0, 1), (1, 2), (1, 2), (2, 3)]
g.add_edges(edges)
g.es[:]["dist"] = [1, 2, 3, 4]
I know I can get the id of an edge, and then the attributes as follows, but this only seems to find the last added e.g:
g.get_eid((0, 1)) # returns 0
g.get_eid((1, 2)) # returns 2
So, there are two edges between 1 and 2, but only one is returned by get_eid - I need to know both to then query the edge attributes and return the weightings, to select the correct minimum distances from the graph, as were used by a distance-weighted shortest path query. Is there a way to do this with igraph?