35 #endif // GUM_NO_INLINE 53 for (
const auto node : hardEvidence)
55 for (
const auto node : softEvidence)
57 while (!anc_to_visit.
empty()) {
61 if (!ev_ancestors.exists(node)) {
62 ev_ancestors.insert(node);
63 for (
const auto par : dag.
parents(node)) {
79 for (
const auto node : query) {
80 nodes_to_visit.
insert(std::pair< NodeId, bool >(node,
true));
85 while (!nodes_to_visit.empty()) {
87 const NodeId node = nodes_to_visit.front().first;
88 const bool direction = nodes_to_visit.front().second;
89 nodes_to_visit.popFront();
94 already_visited = visited_from_child.exists(node);
95 if (!already_visited) { visited_from_child.insert(node); }
97 already_visited = visited_from_parent.exists(node);
98 if (!already_visited) { visited_from_parent.insert(node); }
102 if (!already_visited) {
104 const bool is_hard_evidence = hardEvidence.
exists(node);
105 if (!is_hard_evidence) { requisite.
insert(node); }
108 if (direction && !is_hard_evidence) {
110 for (
const auto par : dag.
parents(node)) {
111 nodes_to_visit.insert(std::pair< NodeId, bool >(par,
true));
115 for (
const auto chi : dag.
children(node)) {
116 nodes_to_visit.insert(std::pair< NodeId, bool >(chi,
false));
119 if (!hardEvidence.
exists(node)) {
121 for (
const auto chi : dag.
children(node)) {
122 nodes_to_visit.insert(std::pair< NodeId, bool >(chi,
false));
125 if (ev_ancestors.exists(node)) {
127 for (
const auto par : dag.
parents(node)) {
128 nodes_to_visit.insert(std::pair< NodeId, bool >(par,
true));
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size size() const
alias for sizeNodes
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Generic doubly linked lists.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.