33 #endif // GUM_NOINLINE 38 bool nodes_resize_policy,
40 bool arcs_resize_policy,
42 bool edges_resize_policy) :
47 UndiGraph(edges_size, edges_resize_policy),
48 DiGraph(arcs_size, arcs_resize_policy) {
73 const std::vector< NodeId >
85 while (!nodeFIFO.
empty()) {
86 current = nodeFIFO.
front();
90 for (
const auto new_one :
neighbours(current)) {
94 mark.
insert(new_one, current);
97 std::vector< NodeId > v;
99 for (current = n1; current != n2; current = mark[current])
100 v.push_back(current);
111 for (
const auto new_one :
parents(current)) {
115 mark.
insert(new_one, current);
118 std::vector< NodeId > v;
120 for (current = n1; current != n2; current = mark[current])
121 v.push_back(current);
135 const std::vector< NodeId >
147 while (!nodeFIFO.
empty()) {
148 current = nodeFIFO.
front();
152 for (
const auto new_one :
neighbours(current)) {
156 mark.
insert(new_one, current);
159 std::vector< NodeId > v;
161 for (current = n1; current != n2; current = mark[current])
162 v.push_back(current);
173 for (
const auto new_one :
parents(current)) {
177 mark.
insert(new_one, current);
180 std::vector< NodeId > v;
182 for (current = n1; current != n2; current = mark[current])
183 v.push_back(current);
194 for (
const auto new_one :
children(current)) {
198 mark.
insert(new_one, current);
201 std::vector< NodeId > v;
203 for (current = n1; current != n2; current = mark[current])
204 v.push_back(current);
218 std::stringstream output;
219 std::stringstream nodeStream;
220 std::stringstream edgeStream;
222 output <<
"digraph \"" 223 <<
"no_name\" {" << std::endl;
224 nodeStream <<
"node [shape = ellipse];" << std::endl;
225 std::string tab =
" ";
227 for (
const auto node :
nodes()) {
228 nodeStream << tab << node <<
";";
231 if (!treatedNodes.
exists(nei))
232 edgeStream << tab << node <<
" -> " << nei <<
" [dir=none];" 235 for (
const auto chi :
children(node))
236 edgeStream << tab << node <<
" -> " << chi <<
";" << std::endl;
238 treatedNodes.
insert(node);
241 output << nodeStream.str() << std::endl
242 << 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.
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.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.