src/work/jacint/dijkstra.cc
author klao
Thu, 11 Mar 2004 15:57:17 +0000
changeset 169 940b13aba5ff
parent 160 f1a7005e9dff
child 170 9091b1ebca27
permissions -rw-r--r--
egy kicsit szebb INVALID
jacint@159
     1
#include <iostream>
jacint@160
     2
#include <fstream>
jacint@159
     3
jacint@159
     4
#include <list_graph.hh>
jacint@160
     5
#include <dimacs.hh>
jacint@159
     6
#include <dijkstra.h>
jacint@160
     7
#include <time_measure.h>
jacint@159
     8
jacint@159
     9
using namespace hugo;
jacint@159
    10
jacint@160
    11
int main(int, char **) {
jacint@159
    12
  typedef ListGraph::NodeIt NodeIt;
jacint@159
    13
  typedef ListGraph::EachEdgeIt EachEdgeIt;
jacint@160
    14
jacint@160
    15
  ListGraph G;
jacint@160
    16
  NodeIt s, t;
jacint@160
    17
  ListGraph::EdgeMap<int> cap(G);
jacint@160
    18
  readDimacsMaxFlow(std::cin, G, s, t, cap);
jacint@160
    19
jacint@160
    20
  std::cout << "dijkstra demo ..." << std::endl;
jacint@159
    21
  
jacint@160
    22
  double pre_time=currTime();
jacint@160
    23
    Dijkstra<ListGraph, int> dijkstra_test(G, s, cap);
jacint@167
    24
    dijkstra_test.run();
jacint@160
    25
  double post_time=currTime();
jacint@160
    26
    
jacint@160
    27
  std::cout << "running time: " << post_time-pre_time << " sec"<< std::endl; 
jacint@159
    28
 
jacint@167
    29
  int hiba=0;
jacint@160
    30
  EachEdgeIt e;
jacint@160
    31
  for ( G.getFirst(e) ; G.valid(e); G.next(e) ) {
jacint@160
    32
    NodeIt u=G.tail(e);
jacint@160
    33
    NodeIt v=G.head(e);
jacint@167
    34
    if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap.get(e) ) {
jacint@167
    35
      std::cout<<"Hiba: "<<dijkstra_test.dist(v) - dijkstra_test.dist(u) - cap.get(e)<<std::endl;
jacint@167
    36
      ++hiba;
jacint@167
    37
    }
jacint@159
    38
  }
jacint@159
    39
jacint@167
    40
  std::cout << "Hibas elek szama: " << hiba << " a " << G.edgeNum() <<"-bol."<< std::endl;
jacint@167
    41
jacint@159
    42
  return 0;
jacint@159
    43
}