lilypond-0.0.1
[lilypond.git] / flower / unionfind.hh
blob8fcc6b438e50baa99db43ae241d2cd13a7622485
1 #ifndef UNIONFIND_HH
2 #define UNIONFIND_HH
3 #include "vray.hh"
5 /// which points of a graph are connected?
6 struct Union_find {
7 void connect(int i, int j);
8 int find(int i);
9 bool equiv(int i, int j) { return find(i) == find(j); }
10 Union_find(int sz);
12 private:
13 svec<int> classes;
17 Union find, a standard algorithm:
19 Union_find represents an undirected graph of N points. You can
20 connect two points using #connect()#. #find(i)# finds a uniquely
21 determined representant of the equivalence class of points
22 connected to #i#.
25 #endif