ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::DfsSchema< G > Class Template Reference

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

Detailed description

template<Graph G>
class ADS::DfsSchema< G >

the discovery and finish times and the kind of each edge, the procedure dfs-schema of the book

Constructor and destructor documentation

◆ DfsSchema()

template<Graph G>
ADS::DfsSchema< G >::DfsSchema ( const G & g)
explicit

Member function documentation

◆ dt()

template<Graph G>
int ADS::DfsSchema< G >::dt ( int u) const
nodiscard
Precondition
\( u \) is a node

◆ ft()

template<Graph G>
int ADS::DfsSchema< G >::ft ( int u) const
nodiscard
Precondition
\( u \) is a node

◆ visit()

template<Graph G>
template<class Edge>
void ADS::DfsSchema< G >::visit ( int u,
Edge && edge )

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}} \]

Precondition
\( u \) is a node not discovered yet
Postcondition
\( u \) is finished after it is discovered

◆ visitAll()

template<Graph G>
template<class Edge>
void ADS::DfsSchema< G >::visitAll ( Edge && edge)

the visits from all the nodes not discovered yet, in increasing order


The documentation for this class was generated from the following file: