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

Lemon SVN svn at lemon.cs.elte.hu
Tue Oct 30 21:44:53 CET 2007


Author: deba
Date: Tue Oct 30 21:44:53 2007
New Revision: 3353

Modified:
   lemon/trunk/lemon/nagamochi_ibaraki.h
   lemon/trunk/lemon/unionfind.h

Log:
Change to new union-find interface



Modified: lemon/trunk/lemon/nagamochi_ibaraki.h
==============================================================================
--- lemon/trunk/lemon/nagamochi_ibaraki.h	(original)
+++ lemon/trunk/lemon/nagamochi_ibaraki.h	Tue Oct 30 21:44:53 2007
@@ -1374,10 +1374,11 @@
       typename AuxGraph::template NodeMap<UEdge> edges(*_aux_graph, INVALID);
       for (typename Ufe::ClassIt c(ufe); c != INVALID; ++c) {
         if (ufe.size(c) == 1) continue;
+	Node cn = ufe.item(c);
         for (typename Ufe::ItemIt r(ufe, c); r != INVALID; ++r) {
-          if (static_cast<Node>(r) == static_cast<Node>(c)) continue;
-          _next->set((*_last)[c], (*_first)[r]);
-          _last->set(c, (*_last)[r]);
+          if (static_cast<Node>(r) == static_cast<Node>(cn)) continue;
+          _next->set((*_last)[cn], (*_first)[r]);
+          _last->set(cn, (*_last)[r]);
           remnodes.push_back(r);
           --_node_num;
         }
@@ -1388,15 +1389,18 @@
 
       for (typename AuxGraph::UEdgeIt e(*_aux_graph);
            e != INVALID; ++e) {
-        Node sn = ufe.find(_aux_graph->source(e));
-        Node tn = ufe.find(_aux_graph->target(e));
-        if ((ufe.size(sn) == 1 && ufe.size(tn) == 1)) {
+	int sc = ufe.find(_aux_graph->source(e));
+	int tc = ufe.find(_aux_graph->target(e));
+        if ((ufe.size(sc) == 1 && ufe.size(tc) == 1)) {
           continue;
         }
-        if (sn == tn) {
+        if (sc == tc) {
           remedges.push_back(e);
           continue;
         }
+        Node sn = ufe.item(sc);
+        Node tn = ufe.item(tc);
+
         EdgeInfo info;
         if (sn < tn) {
           info.source = sn;
@@ -1435,13 +1439,14 @@
 
       for (typename Ufe::ClassIt c(ufe); c != INVALID; ++c) {
         if (ufe.size(c) == 1) continue;
+	Node cn = ufe.item(c);
         Value cutvalue = 0;
-        for (typename AuxGraph::IncEdgeIt e(*_aux_graph, c);
+        for (typename AuxGraph::IncEdgeIt e(*_aux_graph, cn);
              e != INVALID; ++e) {
           cutvalue += (*_aux_capacity)[e];
         }
         
-        (*_aux_cut_value)[c] = cutvalue;
+        (*_aux_cut_value)[cn] = cutvalue;
         
       }
 

Modified: lemon/trunk/lemon/unionfind.h
==============================================================================
--- lemon/trunk/lemon/unionfind.h	(original)
+++ lemon/trunk/lemon/unionfind.h	Tue Oct 30 21:44:53 2007
@@ -474,7 +474,14 @@
           
       }
 
-    }    
+    }
+
+    /// \brief Gives back a representant item of the component.
+    ///
+    /// Gives back a representant item of the component.
+    Item item(int cls) const {
+      return items[classes[cls].firstItem].item;
+    }
 
     /// \brief Removes the component of the given element from the structure.
     ///
@@ -732,6 +739,13 @@
     int find(const Item &item) const {
       return items[index[item]].cls;
     }
+
+    /// \brief Gives back a representant item of the component.
+    ///
+    /// Gives back a representant item of the component.
+    Item item(int cls) const {
+      return items[classes[cls].firstItem].item;
+    }
     
     /// \brief Removes the given element from the structure.
     ///



More information about the Lemon-commits mailing list