73namespace kosaraju_detail
117 template <
class GT,
class Enter,
class Leave>
118 [[gnu::always_inline]]
inline void
135 frames.
push(std::move(here));
162template <AlephGraph GT>
189template <AlephGraph GT>
216template <AlephGraph GT>
223 list.
append(mapped_node<GT>(q));
266template <AlephGraph GT>
277 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
285 for (
long i =
static_cast<long>(
df.size()) - 1,
color = 0; i >= 0; --i)
288 auto bp = mapped_node<GT>(gp);
305 for (
auto it = g.
get_arc_it(); it.has_curr(); it.next_ne())
307 auto a = it.get_curr();
311 auto bs = mapped_node<GT>(gs);
312 auto bt = mapped_node<GT>(gt);
357template <AlephGraph GT>
369 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
375 for (
long i =
static_cast<long>(
df.size()) - 1; i >= 0; --i)
377 auto gp =
df.access(i);
378 auto bp = mapped_node<GT>(gp);
405template <AlephGraph GT>
444template <AlephGraph GT>
465template <AlephGraph GT>
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Stack of the frames of a depth-first search that does not recurse.
T & push(Args &&...args)
Builds a frame on top of the stack.
bool is_empty() const noexcept
Whether the stack has no frames.
T & top() noexcept
The top frame; the stack must not be empty.
void pop() noexcept
Destroys the top frame; the stack must not be empty.
void append(Dlink *node) noexcept
Insert node before this.
T & access(const size_t i) noexcept
Fast access without checking allocation and bound_min_clock checking.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
void next_ne() noexcept(shows_ne)
next() without its check: the current arc must exist.
auto get_tgt_node_ne() const noexcept
Backward-compatible alias: return target node (same as get_node_ne()).
auto get_current_arc_ne() const noexcept
bool has_curr() const noexcept
Return true is the iterator has a current arc.
void reset_arcs() const
Reset all the arcs of graph (the control bits, the state, the counter and the cookie)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
void for_each_arc(Operation &op) const
Unconditionally traverse all the arcs of graph and on each one perform an operation.
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
static void map_arcs(A1 *p, A2 *q) noexcept
Map the arcs through their cookies.
void reset_nodes() const
Reset all the nodes of graph (the control bits, the state, the counter and the cookie)
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
static void map_nodes(N1 *p, N2 *q) noexcept
Map the nodes through their cookies.
#define ARC_COOKIE(p)
Return the arc cookie
void kosaraju_connected_components(const GT &g, DynList< GT > &blk_list, DynList< typename GT::Arc * > &arc_list)
Compute strongly connected components using Kosaraju's algorithm.
#define NODE_COUNTER(p)
Get the counter of a node.
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
GT invert_digraph(const GT &g)
Compute the transpose (arc-reversed) digraph.
#define ARC_BITS(p)
Return the control bits of arc p.
#define NODE_COOKIE(p)
Return the node cookie
size_t kosaraju_scc_count(const GT &g)
Count the number of strongly connected components.
#define NODE_COLOR(p)
Synonymous of NODE_COUNTER.
#define IS_ARC_VISITED(p, bit)
Determine whether the bit field is or not set to one.
bool is_strongly_connected(const GT &g)
Check if a directed graph is strongly connected.
#define NODE_BITS(p)
Get the control bits of a node.
#define ALEPH_FLATTEN
[[gnu::flatten]], or nothing where it would only make the compilation slower.
void search(const GT &g, typename GT::Node *p, Enter enter, Leave leave)
Main namespace for Aleph-w library functions.
static void __dfp_phase1(const GT &g, typename GT::Node *p, DynArray< typename GT::Node * > &df)
static void __dfp_phase2_subgraph(const GT &g, typename GT::Node *p, GT &blk, const int &color)
DFS on transposed graph that builds an SCC subgraph (Phase 2).
static long & df(typename GT::Node *p)
Internal helper: DFS discovery time stored in NODE_COUNTER(p).
static void __dfp_phase2_list(const GT &g, typename GT::Node *p, DynList< typename GT::Node * > &list)
DFS on transposed graph that builds an SCC node list (Phase 2).
static long & color(typename GT::Node *p)
Functor wrapper for Kosaraju's algorithm.
void operator()(const GT &g, DynList< GT > &blk_list, DynList< typename GT::Arc * > &arc_list) const
Compute SCCs returning subgraphs and cross-arcs.
A node that waits for the one that it visits, and the next of its outgoing arcs to look at.
GT::Node * next_target() noexcept
Frame(const GT &g, typename GT::Node *n)
Stack of the frames of a depth-first search that does not recurse.
Utility algorithms and operations for graphs.