It is working...
1.1 --- a/src/work/alpar/f_ed_ka.h Tue Feb 17 13:26:44 2004 +0000
1.2 +++ b/src/work/alpar/f_ed_ka.h Tue Feb 17 14:04:46 2004 +0000
1.3 @@ -19,6 +19,7 @@
1.4 typename Graph::EachNodeIt s,
1.5 typename Graph::EachNodeIt t)
1.6 {
1.7 + typedef typename Graph::NodeIt NodeIt;
1.8 typedef typename Graph::EachNodeIt EachNodeIt;
1.9 typedef typename Graph::EdgeIt EdgeIt;
1.10 typedef typename Graph::EachEdgeIt EachEdgeIt;
1.11 @@ -29,10 +30,10 @@
1.12 T flow_val = 0;
1.13 T aug_val;
1.14
1.15 - for(EachEdgeIt e(G);G.valid(e);G.next(e))
1.16 + for(EachEdgeIt e(G);G.valid(e);G.goNext(e))
1.17 f.set(e,0);
1.18
1.19 - std::queue<EachNodeIt> bfs_queue;
1.20 + std::queue<NodeIt> bfs_queue;
1.21 typename Graph::NodeMap<int> visited(G); //0: unvisited,
1.22 //1: reached by a forward edge
1.23 //2: reached by a backward edge
1.24 @@ -43,7 +44,7 @@
1.25
1.26 augment:
1.27
1.28 - for(EachNodeIt n(G);G.valid(n);G.next(n))
1.29 + for(EachNodeIt n(G);G.valid(n);G.goNext(n))
1.30 visited.set(n,0);
1.31
1.32 visited.set(s,3);
1.33 @@ -55,20 +56,25 @@
1.34
1.35 while(!bfs_queue.empty() && !visited.get(t))
1.36 {
1.37 - EachNodeIt n(bfs_queue.front());
1.38 - for(OutEdgeIt e(G,n);G.valid(e);G.next(e))
1.39 + NodeIt n(bfs_queue.front());
1.40 + bfs_queue.pop();
1.41 + for(OutEdgeIt e(G,n);G.valid(e);G.goNext(e))
1.42 if(f.get(e)<c.get(e) && //FIXME: <
1.43 !visited.get(G.bNode(e)))
1.44 {
1.45 - tree.set(G.bNode(e),e);
1.46 - visited.set(G.bNode(e),1);
1.47 + NodeIt nn(G.bNode(e)); //It improves nothing
1.48 + tree.set(nn,e);
1.49 + visited.set(nn,1);
1.50 + bfs_queue.push(nn);
1.51 }
1.52 - for(InEdgeIt e(G,n);G.valid(e);G.next(e))
1.53 + for(InEdgeIt e(G,n);G.valid(e);G.goNext(e))
1.54 if(f.get(e)>0 && //FIXME: >
1.55 !visited.get(G.bNode(e)))
1.56 {
1.57 - tree.set(G.bNode(e),e);
1.58 - visited.set(G.bNode(e),2);
1.59 + NodeIt nn(G.bNode(e));
1.60 + tree.set(nn,e);
1.61 + visited.set(nn,2);
1.62 + bfs_queue.push(nn);
1.63 }
1.64 }
1.65
1.66 @@ -81,12 +87,12 @@
1.67 gn = visited.get(t)==1 ? G.tail(tree.get(t)) : G.head(tree.get(t));
1.68 while(gn!=s) if(visited.get(gn)==1)
1.69 {
1.70 - //FIXME: nonstandars. gcc extension!
1.71 + //FIXME: nonstandard gcc extension!
1.72 aug_val <?= c.get(tree.get(gn))-f.get(tree.get(gn));
1.73 gn=G.tail(tree.get(gn));
1.74 }
1.75 else {
1.76 - //FIXME: nonstandars. gcc extension!
1.77 + //FIXME: nonstandard gcc extension!
1.78 aug_val <?= f.get(tree.get(gn));
1.79 gn=G.head(tree.get(gn));
1.80 }