Set the move tool active by default.
1 #include <lemon/grid_graph.h>
2 #include <lemon/graph_adaptor.h>
3 #include <lemon/graph_to_eps.h>
12 ///\brief Labirinth example with grid graph.
14 /// Labirinth example with grid graph.
16 /// The input file is:
18 /// \include grid_graph_demo.in
22 /// \image html grid_graph_demo.png
23 /// \image latex grid_graph_demo.eps "The labirinth" width=\textwidth
27 /// \include grid_graph_demo.cc
29 using namespace lemon;
33 ifstream in("grid_graph_demo.in");
35 in >> width >> height;
37 in >> start_x >> start_y;
39 in >> stop_x >> stop_y;
41 GridGraph graph(width, height);
42 GridGraph::Node start = graph(start_x - 1, start_y - 1);
43 GridGraph::Node stop = graph(stop_x - 1, stop_y - 1);
44 GridGraph::NodeMap<bool> filter(graph);
46 for (int j = 0; j < height; ++j) {
48 for (int i = 0; i < width; ++i) {
50 filter[graph(i, j)] = (c == '.');
54 typedef NodeSubGraphAdaptor<GridGraph,
55 GridGraph::NodeMap<bool> > FilteredGraph;
57 FilteredGraph filtered(graph, filter);
59 Bfs<FilteredGraph> bfs(filtered);
60 std::cout << "The length of shortest path: " <<
61 bfs.run(start, stop) << std::endl;
63 FilteredGraph::EdgeMap<bool> path(filtered, false);
65 for (GridGraph::Node node = stop;
66 node != start; node = bfs.predNode(node)) {
67 path[bfs.predEdge(node)] = true;
70 graphToEps(filtered, "grid_graph_demo.eps").scaleToA4().
72 copyright("(C) 2006 LEMON Project").
73 coords(scaleMap(indexMap(graph), 10)).
77 edgeColors(composeMap(ColorSet(), path)).
80 std::cout << "The shortest path is written to grid_graph_demo.eps"