56 template < GUM_DiGraphable G >
59 NodeSet frontier = g.parents(
id);
61 while (!frontier.
empty()) {
63 frontier.
erase(current);
65 for (
const auto p: g.parents(current))
72 template < GUM_DiGraphable G >
75 NodeSet frontier = g.children(
id);
77 while (!frontier.
empty()) {
79 frontier.
erase(current);
81 for (
const auto c: g.children(current))
88 template < GUM_DiGraphable G >
91 return res + g.parents(
id);
94 template < GUM_DiGraphable G >
97 for (
const auto node: ids)
102 template < GUM_UndiGraphable G >
107 for (
const auto node: g.nodes()) {
108 if (res.
exists(node))
continue;
111 while (!frontier.
empty()) {
113 frontier.
erase(current);
114 res.
insert(current, numCC);
115 for (
const auto nei: g.neighbours(current))
124 template < GUM_NodeGraphable G >
129 for (
const auto node: g.nodes()) {
130 if (res.
exists(node))
continue;
133 while (!frontier.
empty()) {
135 frontier.
erase(current);
136 res.
insert(current, numCC);
139 for (
const auto n: g.parents(current))
141 for (
const auto n: g.children(current))
145 for (
const auto n: g.neighbours(current))
155 template < GUM_UndiGraphable G >
158 if (!(A * B).empty())
return true;
162 for (
const auto s: A)
165 while (!frontier.
empty()) {
168 for (
const auto v: g.neighbours(u)) {
169 if (visited.
exists(v))
continue;
178 template < GUM_MixedGraphable G >
183 while (!frontier.
empty()) {
187 for (
const auto nei: g.neighbours(n))
194 template < GUM_MixedGraphable G >
196 return g.neighbours(node) + g.parents(node) + g.children(node);
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.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
bool exists(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.
Concept for directed graphs (arcs with parents/children).
Concept for undirected graphs (edges with neighbours).
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeSet descendants(const G &g, NodeId id)
Returns the set of all descendants of id (nodes reachable from id following arc direction).
NodeSet ancestors(const G &g, NodeId id)
Returns the set of all ancestors of id (nodes from which id is reachable following arc direction).
bool areConnected(const G &g, const NodeSet &A, const NodeSet &B)
Returns true iff some node in A can reach some node in B via undirected edges.
NodeSet boundary(const G &g, NodeId node)
Returns the boundary of node: neighbours ∪ parents ∪ children.
NodeProperty< NodeId > chainComponents(const G &g)
Returns a node-to-component-id mapping for the chain components of g (connected components of the edg...
NodeSet chainComponent(const G &g, NodeId node)
Returns the chain component of node in g.
NodeSet family(const G &g, NodeId id)
Returns the family of id : { id } ∪ parents(id).
NodeProperty< NodeId > connectedComponents(const G &g)
Returns a node-to-component-id mapping for the (weakly) connected components of g.
Generic node-reachability algorithms for aGrUM graphs.