]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/unionfind.cc
patch::: 1.1.25.jcn1: jcn1
[lilypond.git] / flower / unionfind.cc
index e7b0831dd1f36acef4416340ae192e87793b454e..1bbf1f409ce279ce8e2b960136949848c4e6c687 100644 (file)
@@ -1,35 +1,37 @@
 #include "unionfind.hh"
 /*
-    see a book on data structures
-    */
+  see a book on data structures
+  */
 
-Union_find::Union_find(int n)
+Union_find::Union_find (int n)
 {
-    classes.set_size(n);
+  classes.set_size (n);
 
-    for (int i=0; i < n; i++) {
+  for (int i=0; i < n; i++) 
+    {
        classes[i] = i;
     }
 }
 
 int
-Union_find::find(int i)
+Union_find::find (int i)
 {
-    int rep = i;
-    while (classes[rep] != rep)
+  int rep = i;
+  while (classes[rep] != rep)
        rep = classes[rep];
-    while (classes[i] != rep) {
+  while (classes[i] != rep) 
+    {
        int next =classes[i];
        classes[i] = rep;
        i = next;
     }
-    return rep;
+  return rep;
 }
 
 void
-Union_find::connect(int i, int j)
+Union_find::connect (int i, int j)
 {
-    i = find(i);
-    j = find(j);
-    classes[i] = j;    
+  i = find (i);
+  j = find (j);
+  classes[i] = j;    
 }