49 inline std::vector< NodeId >
51 std::vector< NodeId > v;
64 template < GUM_DiGraphable G >
71 while (!fifo.
empty()) {
74 for (
const auto n: g.parents(current)) {
75 if (mark.
exists(n))
continue;
85 template < GUM_DiGraphable G >
93 if (mark.
exists(n))
return false;
95 if (n == n1)
return true;
100 while (!fifo.
empty()) {
103 for (
const auto n: g.parents(current))
105 for (
const auto n: g.children(current))
112 template < GUM_DiGraphable G >
114 if (!g.existsNode(from))
return false;
120 while (!fifo.
empty()) {
123 for (
const auto chi: g.children(current)) {
124 if (chi == to)
return true;
135 template < GUM_UndiGraphable G >
142 while (!fifo.
empty()) {
145 for (
const auto n: g.neighbours(current)) {
146 if (mark.
exists(n))
continue;
156 template < GUM_UndiGraphable G >
161 while (!frontier.
empty()) {
163 if (current == n2)
return true;
164 frontier.
erase(current);
166 for (
const auto next: g.neighbours(current))
173 template < GUM_UndiGraphable G >
175 if (except.
contains(n2))
return false;
180 while (!frontier.
empty()) {
182 if (current == n2)
return true;
183 frontier.
erase(current);
185 for (
const auto next: g.neighbours(current))
192 template < GUM_UndiGraphable G >
197 while (!frontier.
empty()) {
199 if (n2.
contains(current))
return true;
200 frontier.
erase(current);
202 for (
const auto next: g.neighbours(current))
209 template < GUM_MixedGraphable G >
217 if (mark.
exists(n))
return false;
219 if (n == n1)
return true;
224 while (!fifo.
empty()) {
227 for (
const auto n: g.neighbours(current))
229 for (
const auto n: g.parents(current))
236 template < GUM_MixedGraphable G >
241 template < GUM_MixedGraphable G >
249 if (mark.
exists(n))
return false;
251 if (n == n1)
return true;
256 while (!fifo.
empty()) {
259 for (
const auto n: g.neighbours(current))
261 for (
const auto n: g.parents(current))
263 for (
const auto n: g.children(current))
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
Generic doubly linked lists.
Val & front() const
Returns a reference to 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.
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.
Exception : the element we looked for cannot be found.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
bool empty() const noexcept
Indicates whether the set is the empty set.
iterator begin() const
The usual unsafe begin iterator to parse the set.
void insert(const Key &k)
Inserts a new element into the set.
void erase(const Key &k)
Erases an element from the set.
#define GUM_ERROR(type, msg)
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
std::vector< NodeId > reconstructPath(const NodeProperty< NodeId > &mark, NodeId n1, NodeId n2)
Reconstruct the BFS path [n1 … n2] from the predecessor mark table.
std::optional< std::vector< NodeId > > undirectedPath(const G &g, NodeId n1, NodeId n2)
Shortest undirected path from n1 to n2 (BFS).
bool hasMixedOrientedPath(const G &g, NodeId n1, NodeId n2)
Returns true if a mixed-oriented path from n1 to n2 exists.
std::optional< std::vector< NodeId > > directedUnorientedPath(const G &g, NodeId n1, NodeId n2)
Shortest path from n1 to n2 ignoring arc orientation (BFS).
std::optional< std::vector< NodeId > > directedPath(const G &g, NodeId n1, NodeId n2)
Shortest directed path from n1 to n2 (BFS, arc direction).
std::optional< std::vector< NodeId > > mixedUnorientedPath(const G &g, NodeId n1, NodeId n2)
Shortest path ignoring all orientations in a mixed graph.
bool hasDirectedPath(const G &g, NodeId from, NodeId to)
Returns true if there is a directed path from from to to.
std::optional< std::vector< NodeId > > mixedOrientedPath(const G &g, NodeId n1, NodeId n2)
Shortest mixed-oriented path from n1 to n2.
bool hasUndirectedPath(const G &g, NodeId n1, NodeId n2)
Returns true if an undirected path exists between n1 and n2.
Generic BFS-based path-finding algorithms for aGrUM graphs.