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 node

  • node2 (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] or None

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

Inheritance diagram of pyagrum.DiGraph, pyagrum.ChainGraph, pyagrum.DAG, pyagrum.MixedGraph, pyagrum.PDAG