src/work/jacint/dijkstra.cc
author jacint
Thu, 22 Apr 2004 14:50:24 +0000
changeset 373 259ea2d741a2
parent 258 94bafec4f56f
permissions -rw-r--r--
Changes in the documentation.
jacint@159
     1
#include <iostream>
jacint@160
     2
#include <fstream>
jacint@159
     3
jacint@372
     4
#include <list_graph.hh>
jacint@372
     5
#include <dimacs.hh>
jacint@159
     6
#include <dijkstra.h>
jacint@160
     7
#include <time_measure.h>
jacint@372
     8
#include <bin_heap.hh>
jacint@170
     9
jacint@159
    10
using namespace hugo;
jacint@159
    11
jacint@160
    12
int main(int, char **) {
jacint@372
    13
  
jacint@372
    14
  typedef ListGraph Graph;
jacint@160
    15
jacint@372
    16
  typedef Graph::Node Node;
jacint@372
    17
  typedef Graph::EdgeIt EdgeIt;
jacint@372
    18
jacint@372
    19
  Graph G;
jacint@211
    20
  Node s, t;
jacint@372
    21
  Graph::EdgeMap<int> cap(G);
jacint@160
    22
  readDimacsMaxFlow(std::cin, G, s, t, cap);
jacint@372
    23
  Timer ts;
jacint@159
    24
  
jacint@372
    25
  std::cout << "Testing dijkstra.h with Fibonacci-heap 
jacint@372
    26
implementation fib_heap.h ..." << std::endl;
jacint@372
    27
  
jacint@372
    28
  Dijkstra<Graph, int
jacint@372
    29
      //      , BinHeap<ListGraph::NodeIt, int, ListGraph::NodeMap<int> > 
jacint@372
    30
> dijkstra_test(G, s, cap);
jacint@372
    31
   ts.reset();
jacint@372
    32
    dijkstra_test.run();
jacint@372
    33
    std::cout << "elapsed time: " << ts << std::endl;
jacint@160
    34
  double post_time=currTime();
jacint@160
    35
    
jacint@372
    36
  std::cout << "running time: " << post_time-pre_time << " sec"<< std::endl; 
jacint@159
    37
 
jacint@372
    38
  EachEdgeIt e;
jacint@170
    39
jacint@372
    40
  int hiba=0;
jacint@372
    41
jacint@372
    42
  int edge=0;
jacint@372
    43
jacint@372
    44
  for ( G.getFirst(e) ; G.valid(e); G.next(e) ) {
jacint@372
    45
    NodeIt u=G.tail(e);
jacint@372
    46
    NodeIt v=G.head(e);
jacint@372
    47
    ++edge;
jacint@372
    48
    if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap.get(e) ) {
jacint@372
    49
      std::cout<<"Hiba: "<<edge<<": "<<dijkstra_test.dist(v) - dijkstra_test.dist(u) - cap.get(e)<<std::endl;
jacint@372
    50
      ++hiba;
jacint@167
    51
    }
jacint@372
    52
  }
jacint@173
    53
jacint@372
    54
  std::cout << "Osszhibas el: " << hiba << " osszel: " << G.edgeNum() << std::endl;
jacint@173
    55
jacint@159
    56
  return 0;
jacint@159
    57
}