1.1 --- a/demo/dijkstra_demo.cc Wed Aug 17 21:52:50 2005 +0000
1.2 +++ b/demo/dijkstra_demo.cc Wed Aug 17 22:07:35 2005 +0000
1.3 @@ -22,12 +22,13 @@
1.4 /// a graph with edge lengths. Here we only show some of the
1.5 /// facilities supplied by our implementation: for the detailed
1.6 /// documentation of the LEMON Dijkstra class read \ref lemon::Dijkstra "this".
1.7 +///
1.8 +/// \include dijkstra_demo.cc
1.9
1.10 #include <iostream>
1.11
1.12 #include <lemon/list_graph.h>
1.13 #include <lemon/dijkstra.h>
1.14 -//#include <lemon/graph_writer.h>
1.15
1.16 using namespace lemon;
1.17
1.18 @@ -69,39 +70,35 @@
1.19 len.set(v4_t, 8);
1.20 len.set(v5_t, 8);
1.21
1.22 - std::cout << "This program is a simple demo of the LEMON Dijkstra class."<<std::endl;
1.23 - std::cout << "We calculate the shortest path from node s to node t in a graph."<<std::endl;
1.24 - std::cout <<std::endl;
1.25 + std::cout << "This program is a simple demo of the LEMON Dijkstra class."
1.26 + << std::endl;
1.27 + std::cout <<
1.28 + "We calculate the shortest path from node s to node t in a graph."
1.29 + << std::endl;
1.30 + std::cout << std::endl;
1.31
1.32
1.33 - std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."<<std::endl;
1.34 + std::cout << "The id of s is " << g.id(s)<< ", the id of t is "
1.35 + << g.id(t) << "." << std::endl;
1.36
1.37 std::cout << "Dijkstra algorithm demo..." << std::endl;
1.38
1.39 -
1.40 Dijkstra<Graph, LengthMap> dijkstra_test(g,len);
1.41
1.42 dijkstra_test.run(s);
1.43 +
1.44 + std::cout << "The distance of node t from node s: "
1.45 + << dijkstra_test.dist(t) << std::endl;
1.46
1.47 + std::cout << "The shortest path from s to t goes through the following "
1.48 + << "nodes (the first one is t, the last one is s): "
1.49 + << std::endl;
1.50 +
1.51 + for (Node v=t;v != s; v=dijkstra_test.predNode(v)) {
1.52 + std::cout << g.id(v) << "<-";
1.53 + }
1.54
1.55 - std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<<std::endl;
1.56 -
1.57 - std::cout << "The shortest path from s to t goes through the following nodes (the first one is t, the last one is s): "<<std::endl;
1.58 -
1.59 - for (Node v=t;v != s; v=dijkstra_test.predNode(v)){
1.60 - std::cout << g.id(v) << "<-";
1.61 - }
1.62 std::cout << g.id(s) << std::endl;
1.63
1.64 -
1.65 return 0;
1.66 }
1.67 -
1.68 -
1.69 -
1.70 -
1.71 -
1.72 -
1.73 -
1.74 -
1.75 -