32 #endif // GUM_NO_INLINE 46 const std::pair< bool, bool > empty_mark(
false,
false);
53 for (
const auto node : query) {
54 nodes_to_visit.
insert(std::pair< NodeId, bool >(node,
true));
59 while (!nodes_to_visit.
empty()) {
64 if (!marks.exists(node)) marks.insert(node, empty_mark);
67 if (nodes_to_visit.
front().second) {
71 if (hardEvidence.
exists(node)) {
continue; }
73 if (!marks[node].first) {
74 marks[node].first =
true;
75 for (
const auto par : dag.
parents(node)) {
76 nodes_to_visit.
insert(std::pair< NodeId, bool >(par,
true));
80 if (!marks[node].second) {
81 marks[node].second =
true;
82 for (
const auto chi : dag.
children(node)) {
83 nodes_to_visit.
insert(std::pair< NodeId, bool >(chi,
false));
89 const bool is_hard_evidence = hardEvidence.
exists(node);
90 const bool is_evidence = is_hard_evidence || softEvidence.
exists(node);
92 if (is_evidence && !marks[node].first) {
93 marks[node].first =
true;
96 for (
const auto par : dag.
parents(node)) {
97 nodes_to_visit.
insert(std::pair< NodeId, bool >(par,
true));
101 if (!is_hard_evidence && !marks[node].second) {
102 marks[node].second =
true;
104 for (
const auto chi : dag.
children(node)) {
105 nodes_to_visit.
insert(std::pair< NodeId, bool >(chi,
false));
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
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.
The class for generic Hash Tables.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
static 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.