30 #endif // GUM_NOINLINE 36 bool nodes_resize_policy,
38 bool arcs_resize_policy) :
40 DiGraph(nodes_size, nodes_resize_policy, arcs_size, arcs_resize_policy) {
55 if (!
exists(from))
return false;
57 if (from == to)
return true;
68 while (!nodeFIFO.
empty()) {
69 new_one = nodeFIFO.
front();
73 for (
const auto chi :
children(new_one)) {
74 if (chi == to)
return true;
90 for (
const auto arc :
arcs())
91 moralgraph.
addEdge(arc.first(), arc.second());
94 for (
const auto node :
nodes()) {
95 const auto& par =
parents(node);
97 for (
auto it1 = par.begin(); it1 != par.end(); ++it1) {
100 for (++it2; it2 != par.end(); ++it2) {
102 moralgraph.
addEdge(*it1, *it2);
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
bool __hasDirectedPath(const NodeId from, const NodeId to)
checks whether there exists a directed path from from to to
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
UndiGraph moralGraph() const
Inline implementation of Base classes for directed acylic graphs.
bool exists(const NodeId id) const
alias for existsNode
Generic doubly linked lists.
gum is the global namespace for all aGrUM entities
void popFront()
Removes the first element of a List, if any.
DAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
Val & pushBack(const Val &val)
Inserts a new element (a copy) at the end of the chained list.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
Base class for all oriented graphs.
Class for node sets in graph.
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
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
Base class for undirected graphs.
void populateNodes(const NodeGraphPart &s)
populateNodes clears *this and fills it with the same nodes as "s"
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.
Base classes for directed acyclic graphs.