[Lemon-commits] deba: r3395 - lemon/trunk/lemon

Lemon SVN svn at lemon.cs.elte.hu
Wed Nov 21 14:34:39 CET 2007


Author: deba
Date: Wed Nov 21 14:34:38 2007
New Revision: 3395

Modified:
   lemon/trunk/lemon/elevator.h
   lemon/trunk/lemon/goldberg_tarjan.h
   lemon/trunk/lemon/preflow.h

Log:
Bugfix in min cut computation



Modified: lemon/trunk/lemon/elevator.h
==============================================================================
--- lemon/trunk/lemon/elevator.h	(original)
+++ lemon/trunk/lemon/elevator.h	Wed Nov 21 14:34:38 2007
@@ -50,11 +50,13 @@
   template<class Graph, class Item>
   class Elevator 
   {
-  private:
+  public:
 
     typedef Item Key;
     typedef int Value;
 
+  private:
+
     typedef typename std::vector<Item>::iterator Vit;
     typedef typename ItemSetTraits<Graph,Item>::template Map<Vit>::Type VitMap;
     typedef typename ItemSetTraits<Graph,Item>::template Map<int>::Type IntMap;
@@ -377,6 +379,16 @@
       _level[i]=new_level;
       if(new_level>_highest_active) _highest_active=new_level;
     }
+
+    ///Mark the node as it did not reach the max level
+    
+    ///Mark the node as it did not reach the max level. It sets the
+    ///level of the node to a low value, which is not connected to the
+    ///real levels of elevator. The node should be lifted previously
+    ///to the top level.
+    void markToBottom(Item i) {
+      _level[i] = - _max_level;
+    }
     
     ///Lift all nodes on and above a level to the top (and deactivate them).
 
@@ -491,11 +503,13 @@
   ///Graph::Edge, Graph::UEdge)
   template <class Graph, class Item>
   class LinkedElevator {
-  private:
+  public:
 
     typedef Item Key;
     typedef int Value;
 
+  private:
+
     typedef typename ItemSetTraits<Graph,Item>::
     template Map<Item>::Type ItemMap;
     typedef typename ItemSetTraits<Graph,Item>::
@@ -882,6 +896,16 @@
       }
     }
     
+    ///Mark the node as it did not reach the max level
+    
+    ///Mark the node as it did not reach the max level. It sets the
+    ///level of the node to a low value, which is not connected to the
+    ///real levels of elevator. The node should be lifted previously
+    ///to the top level.
+    void markToBottom(Item i) {
+      _level[i] = - _max_level;
+    }
+
     ///Lift all nodes on and above a level to the top (and deactivate them).
 
     ///This function lifts all nodes on and above level \c l to \c

Modified: lemon/trunk/lemon/goldberg_tarjan.h
==============================================================================
--- lemon/trunk/lemon/goldberg_tarjan.h	(original)
+++ lemon/trunk/lemon/goldberg_tarjan.h	Wed Nov 21 14:34:38 2007
@@ -395,8 +395,8 @@
     void createStructures() {
       _node_num = countNodes(_graph);
 
-      _max_tree_size = (double(_node_num) * double(_node_num)) / 
-	double(countEdges(_graph));
+      _max_tree_size = int((double(_node_num) * double(_node_num)) / 
+			   double(countEdges(_graph)));
 
       if (!_flow) {
 	_flow = Traits::createFlowMap(_graph);
@@ -827,7 +827,9 @@
       _level->initFinish();
 
       for (NodeIt n(_graph); n != INVALID; ++n) {
-	if ((*_excess)[n] > 0 && _target != n) {
+	if (!reached[n]) {
+	  _level->markToBottom(n);
+	} else if ((*_excess)[n] > 0 && _target != n) {
 	  _level->activate(n);
 	}
       }

Modified: lemon/trunk/lemon/preflow.h
==============================================================================
--- lemon/trunk/lemon/preflow.h	(original)
+++ lemon/trunk/lemon/preflow.h	Wed Nov 21 14:34:38 2007
@@ -711,7 +711,7 @@
     void startSecondPhase() {
       _phase = false;
 
-      typename Graph::template NodeMap<bool> reached(_graph, false);
+      typename Graph::template NodeMap<bool> reached(_graph);
       for (NodeIt n(_graph); n != INVALID; ++n) {
 	reached.set(n, (*_level)[n] < _level->maxLevel());
       }
@@ -751,7 +751,9 @@
       _level->initFinish();
 
       for (NodeIt n(_graph); n != INVALID; ++n) {
-	if ((*_excess)[n] > 0 && _target != n) {
+	if (!reached[n]) {
+	  _level->markToBottom(n);
+	} else if ((*_excess)[n] > 0 && _target != n) {
 	  _level->activate(n);
 	}
       }



More information about the Lemon-commits mailing list