38 #include "DGtal/io/Color.h"
39 #include "DGtal/io/colormaps/GradientColorMap.h"
40 #include "DGtal/io/colormaps/HueShadeColorMap.h"
41 #include "DGtal/io/boards/Board2D.h"
42 #include "DGtal/helpers/StdDefs.h"
43 #include "DGtal/shapes/Shapes.h"
44 #include "DGtal/topology/Object.h"
45 #include "DGtal/graph/BreadthFirstVisitor.h"
46 #include "DGtal/graph/DepthFirstVisitor.h"
47 #include "DGtal/graph/GraphVisitorRange.h"
48 #include "DGtal/graph/CUndirectedSimpleGraph.h"
54 using namespace DGtal;
62 Point p1( -41, -36 ), p2( 18, 18 );
70 Object4_8 g( dt4_8, shape_set );
71 typedef Object4_8 Graph;
88 string specificStyle = p1.className() +
"/Paving";
93 it != itEnd; ++it, ++n )
101 board.
saveEPS(
"graphTraversal-enum.eps");
108 std::vector<Vertex> neighbors;
110 it != itEnd; ++it, ++nn )
113 std::back_insert_iterator< std::vector<Vertex> > neighIt
114 = std::back_inserter( neighbors );
115 g.writeNeighbors( neighIt, vtx );
116 mm += neighbors.size();
119 trace.
info() <<
"Graph has " << nn <<
" vertices and "
120 << (mm/2) <<
" edges." << std::endl;
129 typedef BFSVisitor::Node Node;
130 BFSVisitor bfv( g,
Point( -2, -1 ) );
131 while( ! bfv.finished() )
133 Node node = bfv.current();
136 cmap_grad( node.second ) ) )
140 board.
saveEPS(
"graphTraversal-bfs.eps");
149 VisitorRange range(
new DFSVisitor( g,
Point( -2, -1 ) ) );
152 it != itEnd; ++it, ++n )
160 board.
saveEPS(
"graphTraversal-dfs-range.eps");
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Structure representing an RGB triple with alpha component.
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void addColor(const Color &color)
Aim: Transforms a graph visitor into a single pass input range.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
std::string className() const
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...