COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/jacint/dijkstra.cc @ 169:940b13aba5ff

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

* empty log message *

File size: 1.1 KB
RevLine 
[159]1#include <iostream>
[160]2#include <fstream>
[159]3
4#include <list_graph.hh>
[160]5#include <dimacs.hh>
[159]6#include <dijkstra.h>
[160]7#include <time_measure.h>
[159]8
9using namespace hugo;
10
[160]11int main(int, char **) {
[159]12  typedef ListGraph::NodeIt NodeIt;
13  typedef ListGraph::EachEdgeIt EachEdgeIt;
[160]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;
[159]21 
[160]22  double pre_time=currTime();
23    Dijkstra<ListGraph, int> dijkstra_test(G, s, cap);
[167]24    dijkstra_test.run();
[160]25  double post_time=currTime();
26   
27  std::cout << "running time: " << post_time-pre_time << " sec"<< std::endl;
[159]28 
[167]29  int hiba=0;
[160]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);
[167]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    }
[159]38  }
39
[167]40  std::cout << "Hibas elek szama: " << hiba << " a " << G.edgeNum() <<"-bol."<< std::endl;
41
[159]42  return 0;
43}
Note: See TracBrowser for help on using the repository browser.