# HG changeset patch # User alpar # Date 1079799199 0 # Node ID fc549fac0dd0386ae251dc60a836a25135019456 # Parent 40fcfa5bfc32886b9016fd44a31a6192ca742cc3 Several bugfixes diff -r 40fcfa5bfc32 -r fc549fac0dd0 src/work/jacint/bin_heap.hh --- a/src/work/jacint/bin_heap.hh Sat Mar 20 16:10:26 2004 +0000 +++ b/src/work/jacint/bin_heap.hh Sat Mar 20 16:13:19 2004 +0000 @@ -153,15 +153,16 @@ } void erase(const Key &k) { - rmidx(kim.get(k)); + rmidx(kim[k]); } - const Val get(const Key &k) const { - int idx = kim.get(k); + Val operator[](const Key &k) const { + int idx = kim[k]; return data[idx].second; } + void put(const Key &k, const Val &v) { - int idx = kim.get(k); + int idx = kim[k]; if( idx < 0 ) { push(k,v); } @@ -174,16 +175,16 @@ } void decrease(const Key &k, const Val &v) { - int idx = kim.get(k); + int idx = kim[k]; bubble_up(idx, PairType(k,v)); } void increase(const Key &k, const Val &v) { - int idx = kim.get(k); + int idx = kim[k]; bubble_down(idx, PairType(k,v), data.size()); } state_enum state(const Key &k) const { - int s = kim.get(k); + int s = kim[k]; if( s>=0 ) s=0; return state_enum(s); diff -r 40fcfa5bfc32 -r fc549fac0dd0 src/work/jacint/dijkstra.cc --- a/src/work/jacint/dijkstra.cc Sat Mar 20 16:10:26 2004 +0000 +++ b/src/work/jacint/dijkstra.cc Sat Mar 20 16:13:19 2004 +0000 @@ -25,12 +25,12 @@ std::cout << "dijkstra demo ..." << std::endl; double pre_time=currTime(); - Dijkstra > > dijkstra_test(G, cap); - dijkstra_test.run(s); + dijkstra_test.run(s); double post_time=currTime(); - std::cout << "running time with fib_heap: " + std::cout << "running time with fib_heap: " << post_time-pre_time << " sec"<< std::endl; pre_time=currTime(); @@ -50,32 +50,32 @@ InEdgeIt e; for ( G.first(e,u); G.valid(e); G.next(e) ) { Node v=G.tail(e); - if ( dijkstra_test.dist(u) - dijkstra_test.dist(v) > cap.get(e) ) + if ( dijkstra_test.dist(u) - dijkstra_test.dist(v) > cap[e] ) { std::cout<<"Hibas el a fibonaccis Dijkstraban: " << dijkstra_test.dist(u) - dijkstra_test.dist(v) - - cap.get(e)< cap.get(e) ) + if ( dijkstra_test2.dist(u) - dijkstra_test2.dist(v) > cap[e] ) { std::cout<<"Hibas el a binarisos Dijkstraban: " << dijkstra_test2.dist(u) - dijkstra_test2.dist(v) - - cap.get(e)< predecessor; typename Graph::NodeMap distance; + //FIXME: typename Graph::NodeMap reach; + //typename Graph::NodeMap reach; public : @@ -65,7 +67,9 @@ reach.set(u,false); } + //FIXME: typename Graph::NodeMap scanned(G,false); + //typename Graph::NodeMap scanned(G,false); typename Graph::NodeMap heap_map(G,-1); Heap heap(heap_map); @@ -76,7 +80,7 @@ while ( !heap.empty() ) { Node v=heap.top(); - T oldvalue=heap.get(v); + T oldvalue=heap[v]; heap.pop(); distance.set(v, oldvalue); scanned.set(v,true); @@ -90,26 +94,23 @@ reach.set(w,true); heap.push(w,oldvalue+length[e]); predecessor.set(w,e); - } else if ( oldvalue+length[e] < heap.get(w) ) { + } else if ( oldvalue+length[e] < heap[w] ) { predecessor.set(w,e); heap.decrease(w, oldvalue+length[e]); } } } } - } + } - T dist(Node v) { return distance[v]; } - Edge pred(Node v) { return predecessor[v]; } - bool reached(Node v) { return reach[v]; } diff -r 40fcfa5bfc32 -r fc549fac0dd0 src/work/jacint/fib_heap.h --- a/src/work/jacint/fib_heap.h Sat Mar 20 16:10:26 2004 +0000 +++ b/src/work/jacint/fib_heap.h Sat Mar 20 16:13:19 2004 +0000 @@ -94,7 +94,7 @@ void set (Item const it, PrioType const value) { - int i=iimap.get(it); + int i=iimap[it]; if ( i >= 0 && container[i].in ) { if ( comp(value, container[i].prio) ) decrease(it, value); if ( comp(container[i].prio, value) ) increase(it, value); @@ -103,7 +103,7 @@ void push (Item const it, PrioType const value) { - int i=iimap.get(it); + int i=iimap[it]; if ( i < 0 ) { int s=container.size(); iimap.set( it, s ); @@ -145,19 +145,17 @@ - PrioType& operator[](const Item& it) const { - return container[iimap.get(it)].prio; + PrioType& operator[](const Item& it) { + return container[iimap[it]].prio; } const PrioType& operator[](const Item& it) const { - return container[iimap.get(it)].prio; + return container[iimap[it]].prio; } - const PrioType get(const Item& it) const { - return container[iimap.get(it)].prio; - } - - +// const PrioType get(const Item& it) const { +// return container[iimap[it]].prio; +// } void pop() { /*The first case is that there are only one root.*/ @@ -192,7 +190,7 @@ void erase (const Item& it) { - int i=iimap.get(it); + int i=iimap[it]; if ( i >= 0 && container[i].in ) { if ( container[i].parent!=-1 ) { @@ -207,7 +205,7 @@ void decrease (Item it, PrioType const value) { - int i=iimap.get(it); + int i=iimap[it]; container[i].prio=value; int p=container[i].parent; @@ -226,7 +224,7 @@ state_enum state(const Item &it) const { - int i=iimap.get(it); + int i=iimap[it]; if( i>=0 ) { if ( container[i].in ) i=0; else i=-2;