DGtal 1.4.0
|
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or set (called initial core). More...
#include <DGtal/graph/BreadthFirstVisitor.h>
Public Types | |
typedef BreadthFirstVisitor< TGraph, TMarkSet > | Self |
typedef TGraph | Graph |
typedef TMarkSet | MarkSet |
typedef Graph::Size | Size |
typedef Graph::Vertex | Vertex |
typedef Size | Data |
Data attached to each Vertex is the topological distance to the seed. | |
typedef std::pair< Vertex, Data > | Node |
FIXME. | |
typedef std::queue< Node > | NodeQueue |
Internal data structure for computing the breadth-first expansion. | |
typedef std::vector< Vertex > | VertexList |
Internal data structure for storing vertices. | |
Public Member Functions | |
~BreadthFirstVisitor () | |
BreadthFirstVisitor (const BreadthFirstVisitor &other) | |
BreadthFirstVisitor (ConstAlias< Graph > graph) | |
BreadthFirstVisitor (ConstAlias< Graph > graph, const Vertex &p) | |
template<typename VertexIterator > | |
BreadthFirstVisitor (ConstAlias< 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 | |
BreadthFirstVisitor () | |
Private Member Functions | |
BreadthFirstVisitor & | operator= (const BreadthFirstVisitor &other) |
Private Attributes | |
const Graph & | myGraph |
MarkSet | myMarkedVertices |
NodeQueue | myQueue |
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or set (called initial core).
Description of template class 'BreadthFirstVisitor'
The expander implements a breadth-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. Each layer is at a different distance from the initial core. The expander move layer by layer but the user is free to navigate on each layer.
TGraph | the type of the graph (models of CUndirectedSimpleLocalGraph). |
Definition at line 94 of file BreadthFirstVisitor.h.
typedef Size DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Data |
Data attached to each Vertex is the topological distance to the seed.
Definition at line 103 of file BreadthFirstVisitor.h.
typedef TGraph DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Graph |
Definition at line 99 of file BreadthFirstVisitor.h.
typedef TMarkSet DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::MarkSet |
Definition at line 100 of file BreadthFirstVisitor.h.
typedef std::pair< Vertex, Data > DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Node |
FIXME.
Type stocking the vertex and its topological distance wrt the initial point or set.
Definition at line 115 of file BreadthFirstVisitor.h.
typedef std::queue< Node > DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::NodeQueue |
Internal data structure for computing the breadth-first expansion.
Definition at line 117 of file BreadthFirstVisitor.h.
typedef BreadthFirstVisitor<TGraph,TMarkSet> DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Self |
Definition at line 98 of file BreadthFirstVisitor.h.
typedef Graph::Size DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Size |
Definition at line 101 of file BreadthFirstVisitor.h.
typedef Graph::Vertex DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::Vertex |
Definition at line 102 of file BreadthFirstVisitor.h.
typedef std::vector< Vertex > DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::VertexList |
Internal data structure for storing vertices.
Definition at line 119 of file BreadthFirstVisitor.h.
DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::~BreadthFirstVisitor | ( | ) |
Destructor.
DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::BreadthFirstVisitor | ( | const BreadthFirstVisitor< TGraph, TMarkSet > & | other | ) |
Copy constructor.
other | the object to clone. |
DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::BreadthFirstVisitor | ( | ConstAlias< Graph > | graph | ) |
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 breadth first traversal takes place. |
DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::BreadthFirstVisitor | ( | ConstAlias< Graph > | graph, |
const Vertex & | p ) |
Constructor from a point. This point provides the initial core of the visitor.
graph | the graph in which the breadth first traversal takes place. |
p | any vertex of the graph. |
DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::BreadthFirstVisitor | ( | ConstAlias< Graph > | graph, |
VertexIterator | b, | ||
VertexIterator | e ) |
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 breadth first traversal. These vertices will all have a topological distance 0.
VertexIterator | any type of single pass iterator on vertices. |
graph | the graph in which the breadth first traversal takes place. |
b | the begin iterator in a container of vertices. |
e | the end iterator in a container of vertices. |
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
const Node & DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::current | ( | ) | const |
NB: valid only if not 'finished()'.
Referenced by main(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), testBreadthFirstPropagation(), testDepthFirstPropagation(), testDigitalSurface(), and testDistancePropagation().
void DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand | ( | ) |
Goes to the next vertex and take into account the current vertex for determining the future visited vertices. NB: valid only if not 'finished()'.
Referenced by main(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), testBreadthFirstPropagation(), testDepthFirstPropagation(), testDigitalSurface(), and testDistancePropagation().
void DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand | ( | const VertexPredicate & | authorized_vtx | ) |
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()'.
bool DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::finished | ( | ) | const |
Referenced by main(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), testBreadthFirstPropagation(), testDepthFirstPropagation(), testDigitalSurface(), and testDistancePropagation().
const Graph & DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::graph | ( | ) | const |
void DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::ignore | ( | ) |
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()'.
Referenced by main().
bool DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
const MarkSet & DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::markedVertices | ( | ) | const |
Referenced by testDigitalSurface().
|
private |
Assignment.
other | the object to copy. |
void DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
void DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::terminate | ( | ) |
Force termination of the breadth 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.
MarkSet DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::visitedVertices | ( | ) | const |
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.
|
private |
The graph where the traversal takes place.
Definition at line 276 of file BreadthFirstVisitor.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 283 of file BreadthFirstVisitor.h.
|
private |
Queue storing the vertices that are the next visited ones in the breadth-first traversal of the graph.
Definition at line 289 of file BreadthFirstVisitor.h.