|
ADS
Algorithms and Data Structures
|
the discovery and finish times and the kind of each edge, the procedure dfs-schema of the book More...
#include <ADS/graph/Visit.h>
Public member functions | |
| DfsSchema (const G &g) | |
| template<class Edge> | |
| void | visit (int u, Edge &&edge) |
| the visit from \( u \); edge( u , v , k ) on each edge examined, of kind \( k \) | |
| template<class Edge> | |
| void | visitAll (Edge &&edge) |
| the visits from all the nodes not discovered yet, in increasing order | |
| int | dt (int u) const |
| int | ft (int u) const |
the discovery and finish times and the kind of each edge, the procedure dfs-schema of the book
|
explicit |
|
nodiscard |
|
nodiscard |
the visit from \( u \); edge( u , v , k ) on each edge examined, of kind \( k \)
In pseudocode (the procedure dfs-schema of section 9.5), with the clock t:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{visit}( u )\quad \triangleright \ \mathit{dt} , \mathit{ft} \text{ the discovery and the finish times, } 0 \text{ unset} \cr 2 & \quad t \gets t + 1;\ \mathit{dt}[ u ] \gets t \cr 3 & \quad \textbf{foreach}\ v \in G.\mathrm{adj}( u )\ \textbf{do} \cr 4 & \qquad \textbf{if}\ \mathit{dt}[ v ] = 0\ \textbf{then} \ \mathrm{edge}( u , v , \text{tree} );\ \mathrm{visit}( v ) \cr 5 & \qquad \textbf{else if}\ \mathit{ft}[ v ] = 0\ \textbf{then} \ \mathrm{edge}( u , v , \text{back} )\quad \triangleright\ v \text{ is an open ancestor} \cr 6 & \qquad \textbf{else if}\ \mathit{dt}[ v ] > \mathit{dt}[ u ] \ \textbf{then}\ \mathrm{edge}( u , v , \text{forward} )\quad \triangleright\ \text{a closed descendant} \cr 7 & \qquad \textbf{else}\ \mathrm{edge}( u , v , \text{cross} ) \cr 8 & \quad t \gets t + 1;\ \mathit{ft}[ u ] \gets t \end{array}} \]
the visits from all the nodes not discovered yet, in increasing order