graph.hasDirectedPath
- pyagrum.graph.hasDirectedPath(g, source, target)
Whether a directed path exists between two nodes (family A).
- Parameters:
g (
DiGraph | DAG | MixedGraph | PDAG | ChainGraph | CPDAG | MPDAG | EssentialGraph) – the graph (its edges are ignored)source (
int | str) – the first node of the pathtarget (
int | str) – the last node of the path
- Returns:
True if there is a directed path from
sourcetotarget- Return type:
bool
Example
import pyagrum as gum
import pyagrum.graph as gg
g = gum.fastPDAG("A->B-C")
gg.hasDirectedPath(g, "A", "B")
# True
gg.hasDirectedPath(g, "A", "C") # the edge B-C is ignored
# False