57#include <unordered_set>
67 if (ug.existsNode(z)) ug.eraseNode(z);
70 inline void removeConditioningNodes(
UndiGraph& ug,
const NodeSet& Z) { _eraseAll(ug, Z); }
100 std::vector< NodeId > ch;
139 removeConditioningNodes(ug, Z);
Detect barren nodes for inference in Bayesian networks.
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
NodeSet children(const NodeSet &ids) const
returns the set of nodes which consists in the node and its parents returns the set of children of a ...
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
The base class for all directed edges.
Detect barren nodes for inference in Bayesian networks.
void setEvidence(const NodeSet *observed_nodes)
sets the observed nodes in the DAG
void setTargets(const NodeSet *target_nodes)
sets the set of target nodes we are interested in
NodeSet barrenNodes()
returns the set of barren nodes
bool dSeparation(NodeId X, NodeId Y, const NodeSet &Z) const
check if node X and node Y are independent given nodes Z (in the sense of d-separation)
UndiGraph moralizedAncestralGraph(const NodeSet &nodes) const
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
NodeSet ancestors(NodeId id) const
returns the set of all ancestors of id (nodes from which id is reachable)
void eraseNode(const NodeId id) override
remove a node and its adjacent arcs from the graph
NodeSet descendants(NodeId id) const
returns the set of all descendants of id (nodes reachable from id)
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
static DAG reduceForDSeparation(const DAG &dag, const NodeSet &X, const NodeSet &Y, const NodeSet &Z)
Barren-node pruning relative to the interest set (X \cup Y \cup Z).
static bool isDSeparated(const DAG &dag, const NodeSet &X, const NodeSet &Y, const NodeSet &Z)
Test ( X \perp!!!\perp Y \mid Z ) (general d-separation).
static bool isAncestorOf(const DAG &dag, NodeId x, NodeId y)
Is x an ancestor of y?
static NodeSet findBarrenNodes(const DAG &dag, const NodeSet &evidenceZ, const NodeSet &targetsXY)
Compute barren nodes given evidence and targets.
static bool isForwardSeparated(const DAG &dag, const NodeSet &X, const NodeSet &Y, const NodeSet &Z)
Forward-style restriction: only paths whose first edge leaves X.
static bool isDescendantOf(const DAG &dag, NodeId x, NodeId y)
Is x a descendant of y?
static bool anyUndirectedConnection(const UndiGraph &ug, const NodeSet &A, const NodeSet &B)
Check if any node in A is undirected-connected to any node in B.
static bool isBackdoorSeparated(const DAG &dag, const NodeSet &X, const NodeSet &Y, const NodeSet &Z)
Backdoor-style restriction: only paths whose first edge points into X.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
void insert(const Key &k)
Inserts a new element into the set.
Size size() const noexcept
Returns the number of elements in the set.
Base class for undirected graphs.
void addEdge(NodeId first, NodeId second) override
insert a new edge into the undirected graph
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
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.
gum is the global namespace for all aGrUM entities
Generic node-reachability algorithms for aGrUM graphs.