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 );
64 DigitalSet shape_set(
domain );
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");