Until this commitment gui gave us segmentation fault in the case when no element was on graph_displayer_canvas and a map to visualize by a property has been changed.
2 * demo/lp_maxflow_demo.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
19 ///\brief Demonstrating LEMON implementation of the Dijkstra algorithm
21 /// Dijkstra's algorithm computes shortest paths between two nodes in
22 /// a graph with edge lengths. Here we only show some of the
23 /// facilities supplied by our implementation: for the detailed
24 /// documentation of the LEMON Dijkstra class read \ref lemon::Dijkstra "this".
28 #include <lemon/list_graph.h>
29 #include <lemon/dijkstra.h>
30 //#include <lemon/graph_writer.h>
32 using namespace lemon;
35 int main (int, char*[])
38 typedef ListGraph Graph;
39 typedef Graph::Node Node;
40 typedef Graph::Edge Edge;
41 typedef Graph::EdgeMap<int> LengthMap;
45 //An example from Ahuja's book
54 Edge s_v2=g.addEdge(s, v2);
55 Edge s_v3=g.addEdge(s, v3);
56 Edge v2_v4=g.addEdge(v2, v4);
57 Edge v2_v5=g.addEdge(v2, v5);
58 Edge v3_v5=g.addEdge(v3, v5);
59 Edge v4_t=g.addEdge(v4, t);
60 Edge v5_t=g.addEdge(v5, t);
72 std::cout << "This program is a simple demo of the LEMON Dijkstra class."<<std::endl;
73 std::cout << "We calculate the shortest path from node s to node t in a graph."<<std::endl;
74 std::cout <<std::endl;
77 std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."<<std::endl;
79 std::cout << "Dijkstra algorithm demo..." << std::endl;
82 Dijkstra<Graph, LengthMap> dijkstra_test(g,len);
87 std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<<std::endl;
89 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;
91 for (Node v=t;v != s; v=dijkstra_test.predNode(v)){
92 std::cout << g.id(v) << "<-";
94 std::cout << g.id(s) << std::endl;