graph.undirectedPath
- pyagrum.graph.undirectedPath(g, source, target)
A shortest path of edges between two nodes (family E).
- Parameters:
g (
UndiGraph | MixedGraph | PDAG | ChainGraph | CPDAG | MPDAG | EssentialGraph) – the graph (its arcs are ignored)source (
int | str) – the first node of the pathtarget (
int | str) – the last node of the path
- Returns:
the nodes of the path, from
sourcetotarget, or None if there is no path- Return type:
list[int] | None
Example
import pyagrum as gum
import pyagrum.graph as gg
g = gum.fastMixedGraph("A-B-C;A->D")
gg.undirectedPath(g, "C", "A")
# [2, 1, 0]
print(gg.undirectedPath(g, "A", "D")) # the arc A->D is ignored
# None