COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/jacint/dijkstra.cc @ 167:7949a29a334e

Last change on this file since 167:7949a29a334e was 167:7949a29a334e, checked in by jacint, 17 years ago

* empty log message *

File size: 1.1 KB
Line 
1#include <iostream>
2#include <fstream>
3
4#include <list_graph.hh>
5#include <dimacs.hh>
6#include <dijkstra.h>
7#include <time_measure.h>
8
9using namespace hugo;
10
11int main(int, char **) {
12  typedef ListGraph::NodeIt NodeIt;
13  typedef ListGraph::EachEdgeIt EachEdgeIt;
14
15  ListGraph G;
16  NodeIt s, t;
17  ListGraph::EdgeMap<int> cap(G);
18  readDimacsMaxFlow(std::cin, G, s, t, cap);
19
20  std::cout << "dijkstra demo ..." << std::endl;
21 
22  double pre_time=currTime();
23    Dijkstra<ListGraph, int> dijkstra_test(G, s, cap);
24    dijkstra_test.run();
25  double post_time=currTime();
26   
27  std::cout << "running time: " << post_time-pre_time << " sec"<< std::endl;
28 
29  int hiba=0;
30  EachEdgeIt e;
31  for ( G.getFirst(e) ; G.valid(e); G.next(e) ) {
32    NodeIt u=G.tail(e);
33    NodeIt v=G.head(e);
34    if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap.get(e) ) {
35      std::cout<<"Hiba: "<<dijkstra_test.dist(v) - dijkstra_test.dist(u) - cap.get(e)<<std::endl;
36      ++hiba;
37    }
38  }
39
40  std::cout << "Hibas elek szama: " << hiba << " a " << G.edgeNum() <<"-bol."<< std::endl;
41
42  return 0;
43}
Note: See TracBrowser for help on using the repository browser.