DiGraph.directedPath
- DiGraph.directedPath(node1, node2)
Return a shortest directed path from node1 to node2, or None if no such path exists.
- Parameters:
node1 (
int) – id of the source nodenode2 (
int) – id of the destination node
- Returns:
ordered list of node ids along the directed path, or None if node2 is unreachable from node1
- Return type:
list[int]orNone
Example
import pyagrum as gum
g = gum.fastDiGraph("A->B->C;A->D->C")
g.directedPath(0, 2)
# [0, 3, 2]
print(g.directedPath(2, 0))
# None
Used by
DiGraph, ChainGraph, DAG, MixedGraph, PDAG
