30 #endif // GUM_NOINLINE 35 bool nodes_resize_policy,
37 bool arcs_resize_policy,
39 bool edges_resize_policy) :
44 UndiGraph(edges_size, edges_resize_policy),
45 DiGraph(arcs_size, arcs_resize_policy) {
70 const std::vector< NodeId >
82 while (!nodeFIFO.
empty()) {
83 current = nodeFIFO.
front();
87 for (
const auto new_one :
neighbours(current)) {
91 mark.
insert(new_one, current);
94 std::vector< NodeId > v;
96 for (current = n1; current != n2; current = mark[current])
108 for (
const auto new_one :
parents(current)) {
112 mark.
insert(new_one, current);
115 std::vector< NodeId > v;
117 for (current = n1; current != n2; current = mark[current])
118 v.push_back(current);
132 const std::vector< NodeId >
144 while (!nodeFIFO.
empty()) {
145 current = nodeFIFO.
front();
149 for (
const auto new_one :
neighbours(current)) {
153 mark.
insert(new_one, current);
156 std::vector< NodeId > v;
158 for (current = n1; current != n2; current = mark[current])
159 v.push_back(current);
170 for (
const auto new_one :
parents(current)) {
174 mark.
insert(new_one, current);
177 std::vector< NodeId > v;
179 for (current = n1; current != n2; current = mark[current])
180 v.push_back(current);
191 for (
const auto new_one :
children(current)) {
195 mark.
insert(new_one, current);
198 std::vector< NodeId > v;
200 for (current = n1; current != n2; current = mark[current])
201 v.push_back(current);
215 std::stringstream output;
216 std::stringstream nodeStream;
217 std::stringstream edgeStream;
219 output <<
"digraph \"" 220 <<
"no_name\" {" << std::endl;
221 nodeStream <<
"node [shape = ellipse];" << std::endl;
222 std::string tab =
" ";
224 for (
const auto node :
nodes()) {
225 nodeStream << tab << node <<
";";
228 if (!treatedNodes.
exists(nei))
229 edgeStream << tab << node <<
" -> " << nei <<
" [dir=none];" 232 for (
const auto chi :
children(node))
233 edgeStream << tab << node <<
" -> " << chi <<
";" << std::endl;
235 treatedNodes.
insert(node);
238 output << nodeStream.str() << std::endl
239 << edgeStream.str() << std::endl
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
const std::vector< NodeId > mixedUnorientedPath(const NodeId node1, const NodeId node2) const
returns a mixed/directed path from node1 to node2 in the arc/edge set
const std::string toString() const
to friendly display the content of the ArcGraphPart
virtual const std::string toString() const
to friendly display the content of the MixedGraph
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
Generic doubly linked lists.
gum is the global namespace for all aGrUM entities
void popFront()
Removes the first element of a List, if any.
The class for generic Hash Tables.
const NodeSet & neighbours(const NodeId id) const
returns the set of edges adjacent to a given node
virtual const std::string toDot() const
to friendly display mixed graph in DOT format
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
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.
std::string toString() const
a function to display the set of nodes
Inline implementation of Base classes for mixed graphs.
Class for node sets in graph.
bool exists(const Val &val) const
Checks whether there exists a given element in the list.
MixedGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
const std::string toString() const
to friendly display the content of the EdgeGraphPart
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
Base classes for mixed directed/undirected graphs.
Base class for undirected graphs.
const std::vector< NodeId > mixedOrientedPath(const NodeId node1, const NodeId node2) const
returns a mixed edge/directed arc path from node1 to node2 in the arc/edge set
std::size_t Size
In aGrUM, hashed values are unsigned long int.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
virtual ~MixedGraph()
destructor
#define GUM_ERROR(type, msg)
Base class for mixed graphs.