demo/grid_graph_demo.cc
changeset 1778 4ba7965386fb
parent 1763 49045f2d28d4
child 1875 98698b69a902
equal deleted inserted replaced
3:c6129c32c7a9 4:5792096125f6
     4 #include <lemon/bfs.h>
     4 #include <lemon/bfs.h>
     5 #include <lemon/xy.h>
     5 #include <lemon/xy.h>
     6 
     6 
     7 #include <iostream>
     7 #include <iostream>
     8 #include <fstream>
     8 #include <fstream>
       
     9 
       
    10 ///\ingroup demos
       
    11 ///\file
       
    12 ///\brief Labirinth example with grid graph.
       
    13 ///
       
    14 ///  Labirinth example with grid graph.
       
    15 ///
       
    16 /// The input file is:
       
    17 ///
       
    18 /// \include grid_graph_demo.in
       
    19 ///
       
    20 /// The result:
       
    21 ///
       
    22 /// \image html grid_graph_demo.png
       
    23 /// \image latex grid_graph_demo.eps "The labirinth" width=\textwidth
       
    24 ///
       
    25 /// The source:
       
    26 ///
       
    27 /// \include grid_graph_demo.cc
     9 
    28 
    10 using namespace lemon;
    29 using namespace lemon;
    11 using namespace std;
    30 using namespace std;
    12 
    31 
    13 int main() {
    32 int main() {
    46   for (GridGraph::Node node = stop; 
    65   for (GridGraph::Node node = stop; 
    47        node != start; node = bfs.predNode(node)) {
    66        node != start; node = bfs.predNode(node)) {
    48     path[bfs.predEdge(node)] = true;
    67     path[bfs.predEdge(node)] = true;
    49   }
    68   }
    50   
    69   
    51   graphToEps(filtered, "grid_graph.eps").scaleToA4().
    70   graphToEps(filtered, "grid_graph_demo.eps").scaleToA4().
    52     title("Grid graph").
    71     title("Grid graph").
    53     copyright("(C) 2005 LEMON Project").
    72     copyright("(C) 2005 LEMON Project").
    54     coords(scaleMap(indexMap(graph), 10)).
    73     coords(scaleMap(indexMap(graph), 10)).
    55     enableParallel().
    74     enableParallel().
    56     nodeScale(0.5).
    75     nodeScale(0.5).
    57     drawArrows().
    76     drawArrows().
    58     edgeColors(composeMap(ColorSet(), path)).
    77     edgeColors(composeMap(ColorSet(), path)).
    59     run();
    78     run();
    60   
    79   
    61   std::cout << "The shortest path is written to grid_graph.eps" << std::endl;
    80   std::cout << "The shortest path is written to grid_graph_demo.eps" 
       
    81 	    << std::endl;
    62 
    82 
    63   return 0;
    83   return 0;
    64 }
    84 }