57 bool nodes_resize_policy,
59 bool arcs_resize_policy,
61 bool edges_resize_policy) :
66 DiGraph(arcs_size, arcs_resize_policy) {
97 std::vector< NodeId > v;
107 while (!node_fifo.
empty()) {
108 current = node_fifo.
front();
112 for (
const auto new_one:
neighbours(current)) {
116 mark.
insert(new_one, current);
119 for (current = n1; current != n2; current = mark[current])
120 v.push_back(current);
129 for (
const auto new_one:
parents(current)) {
133 mark.
insert(new_one, current);
136 for (current = n1; current != n2; current = mark[current])
137 v.push_back(current);
159 while (!node_fifo.
empty()) {
160 current = node_fifo.
front();
164 for (
const auto new_one:
neighbours(current)) {
168 mark.
insert(new_one, current);
170 if (new_one == n1) {
return true; }
176 for (
const auto new_one:
parents(current)) {
180 mark.
insert(new_one, current);
182 if (new_one == n1) {
return true; }
192 std::vector< NodeId > v;
203 while (!node_fifo.
empty()) {
204 current = node_fifo.
front();
208 for (
const auto new_one:
neighbours(current)) {
212 mark.
insert(new_one, current);
215 for (current = n1; current != n2; current = mark[current])
216 v.push_back(current);
225 for (
const auto new_one:
parents(current)) {
229 mark.
insert(new_one, current);
231 for (current = n1; current != n2; current = mark[current])
232 v.push_back(current);
240 for (
const auto new_one:
children(current)) {
244 mark.
insert(new_one, current);
247 for (current = n1; current != n2; current = mark[current])
248 v.push_back(current);
264 while (!stack.
empty()) {
277 std::stringstream output;
278 std::stringstream nodeStream;
279 std::stringstream edgeStream;
283 output <<
"digraph \""
284 <<
"no_name\" {" << std::endl;
285 nodeStream <<
"node [shape = ellipse];" << std::endl;
286 std::string tab =
" ";
288 for (
const auto node:
nodes()) {
289 nodeStream << tab << node <<
";";
292 if (!treatedNodes.
exists(nei))
293 edgeStream << tab << node <<
" -> " << nei <<
" [dir=none];" << std::endl;
295 for (
const auto chi:
children(node))
296 edgeStream << tab << node <<
" -> " << chi <<
";" << std::endl;
298 treatedNodes.
insert(node);
301 output << nodeStream.str() << std::endl << edgeStream.str() << std::endl <<
"}" << std::endl;
const NodeSet & parents(NodeId id) const
returns the set of nodes with arc ingoing to a given node
NodeSet children(const NodeSet &ids) const
returns the set of children of a set of nodes
std::string toString() const
to friendly display the content of the ArcGraphPart
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
virtual std::string toString() const
to friendly display the content of the EdgeGraphPart
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Generic doubly linked lists.
Val & front() const
Returns a reference to first element of a list, if any.
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
void popFront()
Removes the first element of a List, if any.
Val & pushBack(const Val &val)
Inserts a new element (a copy) at the end of the chained list.
Base class for mixed graphs.
NodeSet chainComponent(NodeId node) const
returns the set of nodes reachable by undirected path
std::string toString() const override
to friendly display the content of the MixedGraph
std::string toDot() const override
to friendly display mixed graph in DOT format
std::vector< NodeId > mixedUnorientedPath(NodeId node1, NodeId node2) const
returns a mixed/directed path from node1 to node2 in the arc/edge set
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
bool hasMixedOrientedPath(NodeId node1, NodeId node2) const
returns true if a mixed edge/directed arc path from node1 to node2 in the arc/edge set exists.
virtual ~MixedGraph()
destructor
std::vector< NodeId > mixedOrientedPath(NodeId node1, NodeId node2) const
returns a mixed edge/directed arc path from node1 to node2 in the arc/edge set
Class for node sets in graph.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
virtual std::string toString() const
a function to display the set of nodes
iterator begin() const
The usual unsafe begin iterator to parse the set.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
void insert(const Key &k)
Inserts a new element into the set.
bool empty() const noexcept
Indicates whether the set is the empty set.
void erase(const Key &k)
Erases an element from the set.
UndiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Base classes for mixed directed/undirected graphs.
Inline implementation of Base classes for mixed graphs.
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree