DGtal
0.6.devel
|
#include <DepthFirstVisitor.h>
Data Structures | |
struct | ConstIterator |
struct | NodeAccessor |
struct | VertexAccessor |
Public Types | |
typedef DepthFirstVisitor < TGraph, TMarkSet > | Self |
typedef TGraph | Graph |
typedef TMarkSet | MarkSet |
typedef Graph::Size | Size |
typedef Graph::Vertex | Vertex |
typedef std::pair< Vertex, Size > | Node |
typedef std::stack< Node > | NodeQueue |
typedef std::vector< Vertex > | VertexList |
typedef ConstIterator < VertexAccessor > | VertexConstIterator |
typedef ConstIterator < NodeAccessor > | NodeConstIterator |
Public Member Functions | |
~DepthFirstVisitor () | |
DepthFirstVisitor (const Graph &graph) | |
DepthFirstVisitor (const Graph &graph, const Vertex &p) | |
template<typename VertexIterator > | |
DepthFirstVisitor (const Graph &graph, VertexIterator b, VertexIterator e) | |
const Graph & | graph () const |
const Node & | current () const |
void | ignore () |
void | expand () |
template<typename VertexPredicate > | |
void | expand (const VertexPredicate &authorized_vtx) |
bool | finished () const |
void | terminate () |
const MarkSet & | markedVertices () const |
MarkSet | visitedVertices () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Protected Member Functions | |
DepthFirstVisitor () |
Private Member Functions | |
DepthFirstVisitor (const DepthFirstVisitor &other) | |
DepthFirstVisitor & | operator= (const DepthFirstVisitor &other) |
Private Attributes | |
const Graph & | myGraph |
MarkSet | myMarkedVertices |
NodeQueue | myQueue |
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or set (called initial core).
Description of template class 'DepthFirstVisitor'
The expander implements a depth-first algorithm on the graph of adjacencies. It can be used not only to detect connected component but also to identify the layers of the object located at a given distance of a starting set.
The core of the expander is at the beginning the set of points at distance 0. In this visitor, the distance attached to visited nodes correspond to the depth of the node in the breadth-first traveral.
TGraph | the type of the graph (models of CUndirectedSimpleLocalGraph). |
Definition at line 94 of file DepthFirstVisitor.h.
typedef TGraph DGtal::DepthFirstVisitor< TGraph, TMarkSet >::Graph |
Definition at line 99 of file DepthFirstVisitor.h.
typedef TMarkSet DGtal::DepthFirstVisitor< TGraph, TMarkSet >::MarkSet |
Definition at line 100 of file DepthFirstVisitor.h.
typedef std::pair< Vertex, Size > DGtal::DepthFirstVisitor< TGraph, TMarkSet >::Node |
Type stocking the vertex and its topological depth wrt the initial point or set.
Definition at line 113 of file DepthFirstVisitor.h.
typedef ConstIterator<NodeAccessor> DGtal::DepthFirstVisitor< TGraph, TMarkSet >::NodeConstIterator |
const iterator on pair (Vertex,distance) for visiting a graph by following a depth first traversal.
Definition at line 240 of file DepthFirstVisitor.h.
typedef std::stack< Node > DGtal::DepthFirstVisitor< TGraph, TMarkSet >::NodeQueue |
Internal data structure for computing the depth-first expansion.
Definition at line 115 of file DepthFirstVisitor.h.
typedef DepthFirstVisitor<TGraph,TMarkSet> DGtal::DepthFirstVisitor< TGraph, TMarkSet >::Self |
Definition at line 98 of file DepthFirstVisitor.h.
typedef Graph::Size DGtal::DepthFirstVisitor< TGraph, TMarkSet >::Size |
Definition at line 101 of file DepthFirstVisitor.h.
typedef Graph::Vertex DGtal::DepthFirstVisitor< TGraph, TMarkSet >::Vertex |
Definition at line 102 of file DepthFirstVisitor.h.
typedef ConstIterator<VertexAccessor> DGtal::DepthFirstVisitor< TGraph, TMarkSet >::VertexConstIterator |
const iterator on Vertex for visiting a graph by following a depth first traversal.
Definition at line 237 of file DepthFirstVisitor.h.
typedef std::vector< Vertex > DGtal::DepthFirstVisitor< TGraph, TMarkSet >::VertexList |
Internal data structure for storing vertices.
Definition at line 117 of file DepthFirstVisitor.h.
|
inline |
|
inline |
Constructor from the graph only. The visitor is in the state 'finished()'. Useful to create an equivalent of 'end()' iterator.
graph | the graph in which the depth first traversal takes place. |
Definition at line 53 of file DepthFirstVisitor.ih.
|
inline |
Constructor from a point. This point provides the initial core of the visitor.
graph | the graph in which the depth first traversal takes place. |
p | any vertex of the graph. |
Definition at line 61 of file DepthFirstVisitor.ih.
References DGtal::DepthFirstVisitor< TGraph, TMarkSet >::myMarkedVertices, and DGtal::DepthFirstVisitor< TGraph, TMarkSet >::myQueue.
|
inline |
Constructor from iterators. All vertices visited between the iterators should be distinct two by two. The so specified set of vertices provides the initial core of the depth first traversal. These vertices will all have a topological depth. 0.
VertexIterator | any type of single pass iterator on vertices. |
graph | the graph in which the depth first traversal takes place. |
b | the begin iterator in a container of vertices. |
e | the end iterator in a container of vertices. |
Definition at line 72 of file DepthFirstVisitor.ih.
References DGtal::DepthFirstVisitor< TGraph, TMarkSet >::myMarkedVertices, and DGtal::DepthFirstVisitor< TGraph, TMarkSet >::myQueue.
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
|
private |
Copy constructor.
other | the object to clone. Forbidden by default. |
|
inline |
NB: valid only if not 'finished()'.
Definition at line 102 of file DepthFirstVisitor.ih.
|
inline |
Goes to the next vertex and taked into account the current vertex for determining the future vsited vertices. NB: valid only if not 'finished()'.
Definition at line 120 of file DepthFirstVisitor.ih.
|
inline |
Goes to the next vertex and taked into account the current vertex for determining the future visited vertices.
VertexPredicate | a type that satisfies CPredicate on Vertex. |
authorized_vtx | the predicate that should satisfy the visited vertices. |
NB: valid only if not 'finished()'.
Definition at line 147 of file DepthFirstVisitor.ih.
|
inline |
Definition at line 94 of file DepthFirstVisitor.ih.
|
inline |
Definition at line 86 of file DepthFirstVisitor.ih.
|
inline |
Goes to the next vertex but ignores the current vertex for determining the future visited vertices. Otherwise said, no future visited vertex will have this vertex as a father.
NB: valid only if not 'finished()'.
Definition at line 111 of file DepthFirstVisitor.ih.
|
inline |
Checks the validity/consistency of the object.
Definition at line 239 of file DepthFirstVisitor.ih.
|
inline |
Definition at line 189 of file DepthFirstVisitor.ih.
|
private |
Assignment.
other | the object to copy. |
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 225 of file DepthFirstVisitor.ih.
|
inline |
Force termination of the depth first traversal. 'finished()' returns 'true' afterwards and 'current()', 'expand()', 'ignore()' have no more meaning. Furthermore, 'markedVertices()' and 'visitedVertices()' both represents the set of visited vertices.
Definition at line 174 of file DepthFirstVisitor.ih.
|
inline |
NB: computational cost is a copy of the set of marked vertices then as many deletion as the number of marked vertices yet to be visited.
Definition at line 197 of file DepthFirstVisitor.ih.
|
private |
The graph where the traversal takes place.
Definition at line 390 of file DepthFirstVisitor.h.
|
private |
Set representing the marked vertices: the ones that have been visited and the one that are going to be visited soon (at distance + 1).
Definition at line 397 of file DepthFirstVisitor.h.
Referenced by DGtal::DepthFirstVisitor< TGraph, TMarkSet >::DepthFirstVisitor().
|
private |
Queue storing the vertices that are the next visited ones in the depth-first traversal of the graph.
Definition at line 403 of file DepthFirstVisitor.h.
Referenced by DGtal::DepthFirstVisitor< TGraph, TMarkSet >::DepthFirstVisitor().