![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Namespaces | |
| namespace | detail |
Functions | |
| template<GUM_DiGraphable G> | |
| NodeSet | requisiteNodes (const G &g, const NodeSet &query, const NodeSet &Zhard=NodeSet(), const NodeSet &Zsoft=NodeSet()) |
Returns the Shachter-requisite nodes for query given evidence. | |
| template<GUM_DiGraphable G> | |
| NodeSet | dConnected (const G &g, const NodeSet &query, const NodeSet &Zhard=NodeSet(), const NodeSet &Zsoft=NodeSet()) |
Returns all nodes d-connected to query given evidence. | |
| template<GUM_DiGraphable G, bool CollectAll> | |
| NodeSet | _bayesBall_ (const G &g, const NodeSet &query, const NodeSet &Zhard, const NodeSet &Zsoft) |
| template<GUM_DiGraphable G> | |
| Sequence< NodeId > | topologicalOrder (const G &g) |
Returns a topological ordering of the nodes of g (Kahn's algorithm). | |
| template<GUM_UndiGraphable G> | |
| bool | hasUndirectedCycle (const G &g) |
Returns true if g contains at least one undirected cycle. | |
| template<GUM_DiGraphable G> | |
| DAG | markovBlanket (const G &g, NodeId node, int level=1) |
Returns the level-level Markov blanket of node in g as a DAG. | |
| template<GUM_DiGraphable G> | |
| NodeSet | minimalCondSet (const G &g, NodeId target, const NodeSet &soids) |
Returns the minimal subset of soids that d-connects target. | |
| template<GUM_DiGraphable G> | |
| NodeSet | minimalCondSet (const G &g, const NodeSet &targets, const NodeSet &soids) |
Returns the minimal subset of soids that d-connects all targets. | |
| template<GUM_DiGraphable G> | |
| void | _mcsVisitUp_ (const G &g, NodeId node, const NodeSet &soids, NodeSet &minimal, NodeSet &visitedUp, NodeSet &visitedDn) |
| template<GUM_DiGraphable G> | |
| void | _mcsVisitDn_ (const G &g, NodeId node, const NodeSet &soids, NodeSet &minimal, NodeSet &visitedUp, NodeSet &visitedDn) |
| template<GUM_DiGraphable G> | |
| UndiGraph | moralGraph (const G &g) |
Returns the moral graph of g. | |
| template<GUM_DiGraphable G> | |
| UndiGraph | moralizedAncestralGraph (const G &g, const NodeSet &query) |
Returns the moralized ancestral graph of query in g. | |
| template<GUM_DiGraphable G> | |
| std::optional< std::vector< NodeId > > | directedPath (const G &g, NodeId n1, NodeId n2) |
Shortest directed path from n1 to n2 (BFS, arc direction). | |
| template<GUM_DiGraphable G> | |
| std::optional< std::vector< NodeId > > | directedUnorientedPath (const G &g, NodeId n1, NodeId n2) |
Shortest path from n1 to n2 ignoring arc orientation (BFS). | |
| template<GUM_DiGraphable G> | |
| bool | hasDirectedPath (const G &g, NodeId from, NodeId to) |
Returns true if there is a directed path from from to to. | |
| template<GUM_UndiGraphable G> | |
| std::optional< std::vector< NodeId > > | undirectedPath (const G &g, NodeId n1, NodeId n2) |
Shortest undirected path from n1 to n2 (BFS). | |
| template<GUM_UndiGraphable G> | |
| bool | hasUndirectedPath (const G &g, NodeId n1, NodeId n2) |
Returns true if an undirected path exists between n1 and n2. | |
| template<GUM_UndiGraphable G> | |
| bool | hasUndirectedPath (const G &g, NodeId n1, NodeId n2, const NodeSet &except) |
Returns true if an undirected path from n1 to n2 exists that avoids all nodes in except. | |
| template<GUM_UndiGraphable G> | |
| bool | hasUndirectedPath (const G &g, const NodeSet &n1, const NodeSet &n2, const NodeSet &except) |
Returns true if an undirected path exists from any node in n1 to any node in n2, avoiding nodes in except. | |
| template<GUM_MixedGraphable G> | |
| std::optional< std::vector< NodeId > > | mixedOrientedPath (const G &g, NodeId n1, NodeId n2) |
Shortest mixed-oriented path from n1 to n2. | |
| template<GUM_MixedGraphable G> | |
| bool | hasMixedOrientedPath (const G &g, NodeId n1, NodeId n2) |
Returns true if a mixed-oriented path from n1 to n2 exists. | |
| template<GUM_MixedGraphable G> | |
| std::optional< std::vector< NodeId > > | mixedUnorientedPath (const G &g, NodeId n1, NodeId n2) |
| Shortest path ignoring all orientations in a mixed graph. | |
| template<GUM_DiGraphable G> | |
| NodeSet | ancestors (const G &g, NodeId id) |
Returns the set of all ancestors of id (nodes from which id is reachable following arc direction). | |
| template<GUM_DiGraphable G> | |
| NodeSet | descendants (const G &g, NodeId id) |
Returns the set of all descendants of id (nodes reachable from id following arc direction). | |
| template<GUM_DiGraphable G> | |
| NodeSet | family (const G &g, NodeId id) |
Returns the family of id : { id } ∪ parents(id). | |
| template<GUM_DiGraphable G> | |
| NodeSet | family (const G &g, const NodeSet &ids) |
Returns the union of families of all nodes in ids. | |
| template<GUM_UndiGraphable G> | |
| NodeProperty< NodeId > | chainComponents (const G &g) |
Returns a node-to-component-id mapping for the chain components of g (connected components of the edge-only subgraph). | |
| template<GUM_NodeGraphable G> | |
| NodeProperty< NodeId > | connectedComponents (const G &g) |
Returns a node-to-component-id mapping for the (weakly) connected components of g. | |
| template<GUM_UndiGraphable G> | |
| bool | areConnected (const G &g, const NodeSet &A, const NodeSet &B) |
Returns true iff some node in A can reach some node in B via undirected edges. | |
| template<GUM_MixedGraphable G> | |
| NodeSet | chainComponent (const G &g, NodeId node) |
Returns the chain component of node in g. | |
| template<GUM_MixedGraphable G> | |
| NodeSet | boundary (const G &g, NodeId node) |
Returns the boundary of node: neighbours ∪ parents ∪ children. | |
| template<GUM_DiGraphable G> | |
| bool | dSeparated (const G &g, NodeId X, NodeId Y, const NodeSet &Z) |
Returns true iff X and Y are d-separated by Z in g. | |
| template<GUM_DiGraphable G> | |
| bool | dSeparated (const G &g, const NodeSet &X, const NodeSet &Y, const NodeSet &Z) |
Returns true iff every node in X is d-separated from every node in Y by Z in g. | |
| template<GUM_MixedGraphable G> | |
| bool | cSeparated (const G &g, NodeId X, NodeId Y, const NodeSet &Z) |
Returns true iff X and Y are c-separated by Z in g. | |
| template<GUM_MixedGraphable G> | |
| bool | cSeparated (const G &g, const NodeSet &X, const NodeSet &Y, const NodeSet &Z) |
Returns true iff X and Y are c-separated by Z in g. | |
| NodeSet gum::graph::_bayesBall_ | ( | const G & | g, |
| const NodeSet & | query, | ||
| const NodeSet & | Zhard, | ||
| const NodeSet & | Zsoft ) |
Definition at line 50 of file bayesBall_tpl.h.
References gum::List< Val >::empty(), gum::Set< Key >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::getWithDefault(), gum::List< Val >::insert(), gum::Set< Key >::insert(), and gum::List< Val >::popFront().
Referenced by dConnected(), and requisiteNodes().
| void gum::graph::_mcsVisitDn_ | ( | const G & | g, |
| NodeId | node, | ||
| const NodeSet & | soids, | ||
| NodeSet & | minimal, | ||
| NodeSet & | visitedUp, | ||
| NodeSet & | visitedDn ) |
Definition at line 69 of file minimalConditioningSet_tpl.h.
References _mcsVisitDn_(), _mcsVisitUp_(), and gum::Set< Key >::contains().
Referenced by _mcsVisitDn_(), _mcsVisitUp_(), and minimalCondSet().
| void gum::graph::_mcsVisitUp_ | ( | const G & | g, |
| NodeId | node, | ||
| const NodeSet & | soids, | ||
| NodeSet & | minimal, | ||
| NodeSet & | visitedUp, | ||
| NodeSet & | visitedDn ) |
Definition at line 49 of file minimalConditioningSet_tpl.h.
References _mcsVisitDn_(), _mcsVisitUp_(), and gum::Set< Key >::contains().
Referenced by _mcsVisitDn_(), _mcsVisitUp_(), and minimalCondSet().
Returns the set of all ancestors of id (nodes from which id is reachable following arc direction).
id not included.
Definition at line 57 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
Referenced by gum::DiGraph::ancestors().
| bool gum::graph::areConnected | ( | const G & | g, |
| const NodeSet & | A, | ||
| const NodeSet & | B ) |
Returns true iff some node in A can reach some node in B via undirected edges.
Returns false immediately if A or B is empty, or if both sets share at least one node (trivially connected).
| G | Any GUM_UndiGraphable graph. |
| g | The undirected (or mixed) graph — only edges are traversed. |
| A | First node set. |
| B | Second node set. |
g. Definition at line 156 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::Set< Key >::exists(), and gum::Set< Key >::insert().
Referenced by gum::Separation::anyUndirectedConnection().
Returns the boundary of node: neighbours ∪ parents ∪ children.
Definition at line 195 of file reachability_tpl.h.
Referenced by gum::MixedGraph::boundary().
Returns the chain component of node in g.
The chain component is the connected component of the undirected subgraph (edges only) containing node. Arc orientations are ignored.
Definition at line 179 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
Referenced by gum::MixedGraph::chainComponent().
| NodeProperty< NodeId > gum::graph::chainComponents | ( | const G & | g | ) |
Returns a node-to-component-id mapping for the chain components of g (connected components of the edge-only subgraph).
Arc orientations are ignored; only edges are traversed. Component ids are assigned in order of first encounter.
Definition at line 103 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::HashTable< Key, Val >::exists(), gum::HashTable< Key, Val >::insert(), and gum::Set< Key >::insert().
Referenced by gum::MixedGraph::chainComponents(), and gum::UndiGraph::chainComponents().
| NodeProperty< NodeId > gum::graph::connectedComponents | ( | const G & | g | ) |
Returns a node-to-component-id mapping for the (weakly) connected components of g.
For directed graphs, arcs are treated as undirected (weak connectivity). For mixed graphs, both edges and arcs are traversed. Component ids are assigned in order of first encounter.
| G | Must satisfy GUM_DiGraphable, GUM_UndiGraphable, or both. |
Definition at line 125 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::HashTable< Key, Val >::exists(), gum::HashTable< Key, Val >::insert(), and gum::Set< Key >::insert().
Referenced by gum::DiGraph::connectedComponents(), gum::MixedGraph::connectedComponents(), and gum::UndiGraph::connectedComponents().
| bool gum::graph::cSeparated | ( | const G & | g, |
| const NodeSet & | X, | ||
| const NodeSet & | Y, | ||
| const NodeSet & | Z ) |
Returns true iff X and Y are c-separated by Z in g.
Set-valued version: c-separation holds iff every node in X is disconnected from every node in Y after moralization and removal of Z.
| G | Any GUM_MixedGraphable graph (typically a PDAG or chain graph). |
| g | The mixed graph. |
| X | Source node set (must be disjoint from Y). |
| Y | Target node set (must be disjoint from X). |
| Z | Conditioning set. |
| InvalidArgument | if X and Y are not disjoint. |
Definition at line 73 of file separation_tpl.h.
References GUM_ERROR, gum::Set< Key >::insert(), and moralizedAncestralGraph().
| bool gum::graph::cSeparated | ( | const G & | g, |
| NodeId | X, | ||
| NodeId | Y, | ||
| const NodeSet & | Z ) |
Returns true iff X and Y are c-separated by Z in g.
C-separation generalizes d-separation to mixed graphs (PDAGs / chain graphs). The ancestral subgraph is built by following arcs backward and undirected edges bidirectionally; moralization then marries the parents of each chain component rather than each individual node.
| G | Any GUM_MixedGraphable graph (typically a PDAG or chain graph). |
| g | The mixed graph. |
| X | Source node. |
| Y | Target node. |
| Z | Conditioning set. |
Definition at line 62 of file separation_tpl.h.
References gum::Set< Key >::insert(), and moralizedAncestralGraph().
Referenced by gum::PDAG::cSeparation(), and gum::PDAG::cSeparation().
| NodeSet gum::graph::dConnected | ( | const G & | g, |
| const NodeSet & | query, | ||
| const NodeSet & | Zhard = NodeSet(), | ||
| const NodeSet & | Zsoft = NodeSet() ) |
Returns all nodes d-connected to query given evidence.
Runs the Bayes Ball traversal and collects every visited node (upward or downward), yielding the full d-connected set. Suitable for d-separation testing:
X ⊥ Y | Z iff Y ∉ dConnected(g, {X}, Z)
| G | Any directed graph satisfying GUM_DiGraphable (DAG, DiGraph, …). |
| g | The directed graph. |
| query | Source nodes from which the ball is launched. |
| Zhard | Hard-evidence nodes (conditioning set for d-separation). |
| Zsoft | Soft-evidence nodes: activate colliders without blocking. |
query given the evidence. Definition at line 112 of file bayesBall_tpl.h.
References _bayesBall_().
Referenced by dSeparated(), and dSeparated().
Returns the set of all descendants of id (nodes reachable from id following arc direction).
id not included.
Definition at line 73 of file reachability_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
Referenced by gum::DiGraph::descendants().
| std::optional< std::vector< NodeId > > gum::graph::directedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Shortest directed path from n1 to n2 (BFS, arc direction).
Returns the sequence of nodes [n1, …, n2], or std::nullopt if no directed path exists.
Definition at line 65 of file pathFinding_tpl.h.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), gum::List< Val >::pushBack(), and gum::graph::detail::reconstructPath().
Referenced by gum::DiGraph::directedPath().
| std::optional< std::vector< NodeId > > gum::graph::directedUnorientedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Shortest path from n1 to n2 ignoring arc orientation (BFS).
Traverses both parents and children — shortest path in the skeleton. Returns std::nullopt if no path exists.
Definition at line 86 of file pathFinding_tpl.h.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), gum::List< Val >::pushBack(), and gum::graph::detail::reconstructPath().
Referenced by gum::DiGraph::directedUnorientedPath().
| bool gum::graph::dSeparated | ( | const G & | g, |
| const NodeSet & | X, | ||
| const NodeSet & | Y, | ||
| const NodeSet & | Z ) |
Returns true iff every node in X is d-separated from every node in Y by Z in g.
Implemented via the Bayes Ball algorithm (O(n+e)): X ⊥ Y | Z iff requisiteNodes(g, X, Z) and Y are disjoint.
| G | Any GUM_DiGraphable graph (typically a DAG). |
| g | The directed graph. |
| X | Source node set (must be disjoint from Y). |
| Y | Target node set (must be disjoint from X). |
| Z | Conditioning set (hard evidence). |
| InvalidArgument | if X and Y are not disjoint. |
Definition at line 56 of file separation_tpl.h.
References dConnected(), and GUM_ERROR.
| bool gum::graph::dSeparated | ( | const G & | g, |
| NodeId | X, | ||
| NodeId | Y, | ||
| const NodeSet & | Z ) |
Returns true iff X and Y are d-separated by Z in g.
Implemented via the Bayes Ball algorithm (O(n+e)): X ⊥ Y | Z iff Y is not d-connected to X given Z (i.e. Y ∉ requisiteNodes(g, {X}, Z)).
| G | Any GUM_DiGraphable graph (typically a DAG). |
| g | The directed graph. |
| X | Source node. |
| Y | Target node. |
| Z | Conditioning set (hard evidence). |
Definition at line 49 of file separation_tpl.h.
References dConnected(), gum::Set< Key >::exists(), and gum::Set< Key >::insert().
Referenced by gum::DAG::dSeparation(), and gum::DAG::dSeparation().
Returns the union of families of all nodes in ids.
Definition at line 95 of file reachability_tpl.h.
References family().
Returns the family of id : { id } ∪ parents(id).
Definition at line 89 of file reachability_tpl.h.
Referenced by gum::DiGraph::family(), gum::DiGraph::family(), and family().
| bool gum::graph::hasDirectedPath | ( | const G & | g, |
| NodeId | from, | ||
| NodeId | to ) |
Returns true if there is a directed path from from to to.
Returns false immediately if from does not exist in g.
Definition at line 113 of file pathFinding_tpl.h.
References gum::Set< Key >::contains(), gum::List< Val >::empty(), gum::List< Val >::front(), gum::Set< Key >::insert(), gum::List< Val >::popFront(), and gum::List< Val >::pushBack().
Referenced by gum::DiGraph::hasDirectedPath(), and gum::learning::StructuralConstraintDAG::setGraphAlone().
| bool gum::graph::hasMixedOrientedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Returns true if a mixed-oriented path from n1 to n2 exists.
Definition at line 237 of file pathFinding_tpl.h.
References mixedOrientedPath().
Referenced by gum::MixedGraph::hasMixedOrientedPath().
| bool gum::graph::hasUndirectedCycle | ( | const G & | g | ) |
Returns true if g contains at least one undirected cycle.
Uses BFS per connected component, tracking the predecessor to avoid treating the edge we came from as a back-edge.
Definition at line 88 of file cycleDetection_tpl.h.
References gum::List< Val >::empty(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), and gum::List< Val >::pushBack().
Referenced by gum::UndiGraph::hasUndirectedCycle().
| bool gum::graph::hasUndirectedPath | ( | const G & | g, |
| const NodeSet & | n1, | ||
| const NodeSet & | n2, | ||
| const NodeSet & | except ) |
Returns true if an undirected path exists from any node in n1 to any node in n2, avoiding nodes in except.
Definition at line 193 of file pathFinding_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
| bool gum::graph::hasUndirectedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Returns true if an undirected path exists between n1 and n2.
Definition at line 157 of file pathFinding_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
Referenced by gum::UndiGraph::hasUndirectedPath(), gum::UndiGraph::hasUndirectedPath(), and gum::UndiGraph::hasUndirectedPath().
| bool gum::graph::hasUndirectedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2, | ||
| const NodeSet & | except ) |
Returns true if an undirected path from n1 to n2 exists that avoids all nodes in except.
Definition at line 174 of file pathFinding_tpl.h.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().
| DAG gum::graph::markovBlanket | ( | const G & | g, |
| NodeId | node, | ||
| int | level = 1 ) |
Returns the level-level Markov blanket of node in g as a DAG.
The level-1 Markov blanket contains:
node,node,node).For level k > 1, the same construction is applied iteratively to all newly added nodes at each level, stopping early if no new node is found.
| G | Any GUM_DiGraphable graph (typically a DAG or BayesNet). |
| g | The source directed graph. |
| node | The node whose Markov blanket is computed. |
| level | Depth of the blanket (must be >= 1). |
| InvalidArgument | if node does not exist in g, or level < 1. |
Definition at line 49 of file markovBlanket_tpl.h.
References gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::Set< Key >::empty(), gum::ArcGraphPart::existsArc(), gum::NodeGraphPart::existsNode(), and GUM_ERROR.
Referenced by gum::MarkovBlanket::MarkovBlanket().
| NodeSet gum::graph::minimalCondSet | ( | const G & | g, |
| const NodeSet & | targets, | ||
| const NodeSet & | soids ) |
Returns the minimal subset of soids that d-connects all targets.
Union of minimalCondSet(g, t, soids) over each t ∈ targets.
| G | Any GUM_DiGraphable graph. |
Definition at line 105 of file minimalConditioningSet_tpl.h.
References minimalCondSet().
| NodeSet gum::graph::minimalCondSet | ( | const G & | g, |
| NodeId | target, | ||
| const NodeSet & | soids ) |
Returns the minimal subset of soids that d-connects target.
Computes the smallest S ⊆ soids such that P(target | soids) = P(target | S) in the graph g.
| G | Any GUM_DiGraphable graph. |
| g | The directed graph. |
| target | The query node. |
| soids | The candidate conditioning set. |
Definition at line 89 of file minimalConditioningSet_tpl.h.
References _mcsVisitDn_(), _mcsVisitUp_(), and gum::Set< Key >::contains().
Referenced by gum::DAG::minimalCondSet(), gum::DAG::minimalCondSet(), and minimalCondSet().
| std::optional< std::vector< NodeId > > gum::graph::mixedOrientedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Shortest mixed-oriented path from n1 to n2.
Follows arcs forward and edges in both directions. Returns std::nullopt if no such path exists.
Definition at line 210 of file pathFinding_tpl.h.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), gum::List< Val >::pushBack(), and gum::graph::detail::reconstructPath().
Referenced by hasMixedOrientedPath(), and gum::MixedGraph::mixedOrientedPath().
| std::optional< std::vector< NodeId > > gum::graph::mixedUnorientedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Shortest path ignoring all orientations in a mixed graph.
Traverses edges (both directions), parents, and children. Returns std::nullopt if no path exists.
Definition at line 242 of file pathFinding_tpl.h.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), gum::List< Val >::pushBack(), and gum::graph::detail::reconstructPath().
Referenced by gum::MixedGraph::mixedUnorientedPath().
| UndiGraph gum::graph::moralGraph | ( | const G & | g | ) |
Returns the moral graph of g.
For a directed graph (DAG):
For a mixed graph (PDAG / chain graph):
| G | Any GUM_DiGraphable graph. |
| g | The graph to moralize. |
g. Definition at line 60 of file moralization_tpl.h.
References gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::insert(), and gum::Set< Key >::popFirst().
Referenced by gum::DAG::moralGraph(), gum::PDAG::moralGraph(), and moralizedAncestralGraph().
| UndiGraph gum::graph::moralizedAncestralGraph | ( | const G & | g, |
| const NodeSet & | query ) |
Returns the moralized ancestral graph of query in g.
For a directed graph (DAG): Collects query and all ancestors reachable by following arcs backward, then moralizes the resulting subgraph.
For a mixed graph (PDAG / chain graph): Collects query and all nodes reachable by following arcs backward and undirected edges in both directions, then moralizes with the chain-component rule.
| G | Any GUM_DiGraphable graph. |
| g | The graph. |
| query | The set of nodes whose moralized ancestral graph is needed. |
Definition at line 102 of file moralization_tpl.h.
References gum::DiGraph::addArc(), gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::NodeGraphPart::existsNode(), gum::Set< Key >::insert(), moralGraph(), and gum::NodeGraphPart::nodes().
Referenced by cSeparated(), cSeparated(), gum::DAG::moralizedAncestralGraph(), and gum::PDAG::moralizedAncestralGraph().
| NodeSet gum::graph::requisiteNodes | ( | const G & | g, |
| const NodeSet & | query, | ||
| const NodeSet & | Zhard = NodeSet(), | ||
| const NodeSet & | Zsoft = NodeSet() ) |
Returns the Shachter-requisite nodes for query given evidence.
A node is requisite if it lies on an active path that arrives at a query node from below (upward visit), or if it is evidence that activates a v-structure (collider activation, downward visit). This is the minimal set of nodes whose distributions are needed to compute the posterior of the query.
This is NOT the full d-connected set. Use dConnected when you need all d-connected nodes (e.g. for d-separation testing).
| G | Any directed graph satisfying GUM_DiGraphable (DAG, DiGraph, …). |
| g | The directed graph. |
| query | Source nodes from which the ball is launched. |
| Zhard | Hard-evidence nodes: block upward propagation; activate colliders on downward passes. |
| Zsoft | Soft-evidence nodes: activate colliders without blocking. |
Definition at line 107 of file bayesBall_tpl.h.
References _bayesBall_().
Referenced by gum::BayesBall::requisiteNodes().
Returns a topological ordering of the nodes of g (Kahn's algorithm).
Nodes are ordered so that every arc goes from an earlier to a later position in the sequence.
| InvalidDirectedCycle | if g contains a directed cycle. |
Definition at line 49 of file cycleDetection_tpl.h.
References gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::exists(), GUM_ERROR, gum::HashTable< Key, Val >::insert(), gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::insert(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::size().
Referenced by gum::DiGraph::topologicalOrder().
| std::optional< std::vector< NodeId > > gum::graph::undirectedPath | ( | const G & | g, |
| NodeId | n1, | ||
| NodeId | n2 ) |
Shortest undirected path from n1 to n2 (BFS).
Returns the sequence of nodes [n1, …, n2], or std::nullopt if no path exists.
Definition at line 136 of file pathFinding_tpl.h.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), gum::HashTable< Key, Val >::insert(), gum::List< Val >::popFront(), gum::List< Val >::pushBack(), and gum::graph::detail::reconstructPath().
Referenced by gum::UndiGraph::undirectedPath().