From: fred Date: Sun, 24 Mar 2002 20:15:10 +0000 (+0000) Subject: lilypond-1.1.35 X-Git-Tag: release/1.5.59~2927 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4509505b14ff82961921da2f9fe1ade1d7965d7d;p=lilypond.git lilypond-1.1.35 --- diff --git a/flower/include/unionfind.hh b/flower/include/unionfind.hh index 4f98d8801d..9f360be400 100644 --- a/flower/include/unionfind.hh +++ b/flower/include/unionfind.hh @@ -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 classes; - + /** + This array provides the representing point for each node in the graph. + */ + Array classes_; }; #endif diff --git a/flower/unionfind.cc b/flower/unionfind.cc index 1bbf1f409c..cb5afce6e4 100644 --- a/flower/unionfind.cc +++ b/flower/unionfind.cc @@ -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; }