-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample.cpp
38 lines (34 loc) · 815 Bytes
/
Sample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include "DisjointSets.h"
using namespace std;
void printElementSets(const DisjointSets & s)
{
for (int i = 0; i < s.NumElements(); ++i)
cout << s.FindSet(i) << " ";
cout << endl;
}
int main()
{
DisjointSets s(10);
printElementSets(s);
s.Union(s.FindSet(5),s.FindSet(3));
printElementSets(s);
s.Union(s.FindSet(1),s.FindSet(3));
printElementSets(s);
s.Union(s.FindSet(6),s.FindSet(7));
printElementSets(s);
s.Union(s.FindSet(8),s.FindSet(9));
printElementSets(s);
s.Union(s.FindSet(6),s.FindSet(9));
printElementSets(s);
s.AddElements(3);
printElementSets(s);
s.Union(s.FindSet(11),s.FindSet(12));
printElementSets(s);
s.Union(s.FindSet(9),s.FindSet(10));
printElementSets(s);
s.Union(s.FindSet(7),s.FindSet(11));
printElementSets(s);
system("pause");
return 0;
}