DiGraph.directedUnorientedPath

DiGraph.directedUnorientedPath(node1, node2)

Return a shortest path from node1 to node2 ignoring arc orientation, or None if no path exists.

Parameters:
  • node1 (int) – id of the source node

  • node2 (int) – id of the destination node

Returns:

ordered list of node ids (arcs may be traversed in either direction), or None if unreachable

Return type:

list[int] or None

Example

import pyagrum as gum

g = gum.fastDiGraph("A->B<-C")
g.directedUnorientedPath(0, 2)  # arcs followed in any direction
# [0, 1, 2]
print(g.directedPath(0, 2))
# None

Used by

DiGraph, ChainGraph, DAG, MixedGraph, PDAG

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