]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.1.35
authorfred <fred>
Sun, 24 Mar 2002 20:15:10 +0000 (20:15 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:15:10 +0000 (20:15 +0000)
flower/include/unionfind.hh
flower/unionfind.cc

index 4f98d8801d157fd70faf6038a6eaaaf38c87655f..9f360be4008bbdab449cca205edcc51ad5d722dd 100644 (file)
@@ -2,7 +2,7 @@
 #define UNIONFIND_HH
 #include "array.hh"
 
-/*
+/**
     which points of a graph are connected?.
     Union find, a standard algorithm:
 
@@ -19,7 +19,9 @@ struct Union_find {
     Union_find (int sz);
 
 private:
-    Array<int> classes;
-
+  /**
+     This array provides the representing point for each node in the graph.
+   */
+  Array<int> classes_;
 };
 #endif
index 1bbf1f409ce279ce8e2b960136949848c4e6c687..cb5afce6e4f3470463bfe6c9c79242c304917961 100644 (file)
@@ -5,11 +5,11 @@
 
 Union_find::Union_find (int n)
 {
-  classes.set_size (n);
+  classes_.set_size (n);
 
   for (int i=0; i < n; i++) 
     {
-       classes[i] = i;
+      classes_[i] = i;
     }
 }
 
@@ -17,13 +17,13 @@ int
 Union_find::find (int i)
 {
   int rep = i;
-  while (classes[rep] != rep)
-       rep = classes[rep];
-  while (classes[i] != rep) 
+  while (classes_[rep] != rep)
+    rep = classes_[rep];
+  while (classes_[i] != rep) 
     {
-       int next =classes[i];
-       classes[i] = rep;
-       i = next;
+      int next =classes_[i];
+      classes_[i] = rep;
+      i = next;
     }
   return rep;
 }
@@ -33,5 +33,5 @@ Union_find::connect (int i, int j)
 {
   i = find (i);
   j = find (j);
-  classes[i] = j;    
+  classes_[i] = j;    
 }