32 #endif // GUM_NO_INLINE 50 for (
const auto node : hardEvidence)
52 for (
const auto node : softEvidence)
54 while (!anc_to_visit.
empty()) {
58 if (!ev_ancestors.exists(node)) {
59 ev_ancestors.insert(node);
60 for (
const auto par : dag.
parents(node)) {
76 for (
const auto node : query) {
77 nodes_to_visit.
insert(std::pair< NodeId, bool >(node,
true));
82 while (!nodes_to_visit.empty()) {
84 const NodeId node = nodes_to_visit.front().first;
85 const bool direction = nodes_to_visit.front().second;
86 nodes_to_visit.popFront();
91 already_visited = visited_from_child.exists(node);
92 if (!already_visited) { visited_from_child.insert(node); }
94 already_visited = visited_from_parent.exists(node);
95 if (!already_visited) { visited_from_parent.insert(node); }
99 if (!already_visited) {
101 const bool is_hard_evidence = hardEvidence.
exists(node);
102 if (!is_hard_evidence) { requisite.
insert(node); }
105 if (direction && !is_hard_evidence) {
107 for (
const auto par : dag.
parents(node)) {
108 nodes_to_visit.insert(std::pair< NodeId, bool >(par,
true));
112 for (
const auto chi : dag.
children(node)) {
113 nodes_to_visit.insert(std::pair< NodeId, bool >(chi,
false));
116 if (!hardEvidence.
exists(node)) {
118 for (
const auto chi : dag.
children(node)) {
119 nodes_to_visit.insert(std::pair< NodeId, bool >(chi,
false));
122 if (ev_ancestors.exists(node)) {
124 for (
const auto par : dag.
parents(node)) {
125 nodes_to_visit.insert(std::pair< NodeId, bool >(par,
true));
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
d-separation analysis (as described in Koller & Friedman 2009)
Size size() const
alias for sizeNodes
d-separation analysis (as described in Koller & Friedman 2009)
Generic doubly linked lists.
gum is the global namespace for all aGrUM entities
void popFront()
Removes the first element of a List, if any.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
Generic class for manipulating lists.
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
void requisiteNodes(const DAG &dag, const NodeSet &query, const NodeSet &hardEvidence, const NodeSet &softEvidence, NodeSet &requisite)
Fill the 'requisite' nodeset with the requisite nodes in dag given a query and evidence.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
Val & front() const
Returns a reference to first element of a list, if any.
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
void clear()
Removes all the elements, if any, from the set.
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.