72 for (
const auto node: hardEvidence)
74 for (
const auto node: softEvidence)
76 while (!anc_to_visit.
empty()) {
80 if (!ev_ancestors.
exists(node)) {
82 for (
const auto par: dag.
parents(node)) {
98 for (
const auto node: query) {
99 nodes_to_visit.
insert(std::pair< NodeId, bool >(node,
true));
104 while (!nodes_to_visit.
empty()) {
107 const bool direction = nodes_to_visit.
front().second;
111 bool already_visited;
113 already_visited = visited_from_child.
exists(node);
114 if (!already_visited) { visited_from_child.
insert(node); }
116 already_visited = visited_from_parent.
exists(node);
117 if (!already_visited) { visited_from_parent.
insert(node); }
121 if (!already_visited) {
123 const bool is_hard_evidence = hardEvidence.
exists(node);
124 if (!is_hard_evidence) { requisite.
insert(node); }
127 if (direction && !is_hard_evidence) {
129 for (
const auto par: dag.
parents(node)) {
130 nodes_to_visit.
insert(std::pair< NodeId, bool >(par,
true));
134 for (
const auto chi: dag.
children(node)) {
135 nodes_to_visit.
insert(std::pair< NodeId, bool >(chi,
false));
138 if (!hardEvidence.
exists(node)) {
140 for (
const auto chi: dag.
children(node)) {
141 nodes_to_visit.
insert(std::pair< NodeId, bool >(chi,
false));
144 if (ev_ancestors.
exists(node)) {
146 for (
const auto par: dag.
parents(node)) {
147 nodes_to_visit.
insert(std::pair< NodeId, bool >(par,
true));
const NodeSet & parents(NodeId id) const
returns the set of nodes with arc ingoing to a given node
NodeSet children(const NodeSet &ids) const
returns the set of children of a set of nodes
Generic doubly linked lists.
Val & front() const
Returns a reference to first element of a list, if any.
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
void popFront()
Removes the first element of a List, if any.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
Size size() const
alias for sizeNodes
bool exists(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.
void clear()
Removes all the elements, if any, from the set.
void requisiteNodes(const DAG &dag, const NodeSet &query, const NodeSet &hardEvidence, const NodeSet &softEvidence, NodeSet &requisite) const
Fill the 'requisite' nodeset with the requisite nodes in dag given a query and evidence.
d-separation analysis (as described in Koller & Friedman 2009)
d-separation analysis (as described in Koller & Friedman 2009)
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Generic class for manipulating lists.
gum is the global namespace for all aGrUM entities