> But how can I get the directions of the edges that are passed along the way
> for each path?
If your network is not too large, the easiest is probably to:

1. Convert your original graph into another one where each edge is
present in both directions:

g2 = g.as_undirected()
g2.to_directed(mutual=True)

2. Call g2.get_shortest_paths(v=0, weights="length", output="vpath") -
this will give you each path as a list of vertex indices

3. For each consecutive vertex index pair (i, j), check whether there
is an edge between them in present in g. If so, this is an edge that
follows the directions in the original graph, otherwise it goes
against them:

from itertools import izip

def pairs(iterable):
    return izip(iterable, iterable[1:])

for path in shortest_paths_from_some_source_vertex:
    edge_follows_direction = [g.are_connected(u, v) for u, v in pairs(path)]

Best,
T.

_______________________________________________
igraph-help mailing list
igraph-help@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to