Optionaladjacency: MatrixDirect children of node (nodes with an edge node →).
All descendants of node (including the node itself).
Uses iterative DFS for stack-safety.
Do-surgery: return a new graph with all incoming edges to node removed.
Strict d-separation test: are X and Y conditionally independent given Z?
A trail (path treating edges as undirected) is d-connecting iff:
Two nodes are d-separated by Z iff no d-connecting trail exists between them.
— first node name
— second node name
— conditioning set (node names)
true if X and Y are d-separated given Z
Whether there exists a directed path from from to to.
Undirected neighbors of node (both directions exist).
Resolve a node name to its matrix index; throws if unknown.
Direct parents of node (nodes with an edge → node).
Convert a PDAG (partially directed acyclic graph) to a DAG.
Algorithm (Dor & Tarsi 1992):
a fully directed DAG
Kahn's algorithm for topological ordering.
Convert an undirected edge to directed a→b.
Add an undirected edge (both directions).
Staticfrom
All ancestors of the given nodes (including the nodes themselves). Uses iterative DFS on the transpose graph for stack-safety.