Example #1
0
static list<int> listElements(const DisjointSets &ds, int set)
{
    list<int> elements;
    for (int i = 0; i < ds.NumElements(); ++i)
    {
        if (ds.FindSet(i) == ds.FindSet(set))
            elements.push_front(i);
    }
    return elements;
}
Example #2
0
static list<int> listSets(const DisjointSets &ds)
{
    list<int> sets;
    for (int i = 0; i < ds.NumElements(); ++i)
    {
        if (ds.FindSet(i) == i)
            sets.push_front(i);
    }
    return sets;
}
void printElementSets(const DisjointSets & s)
{
	for (int i = 0; i < s.NumElements(); ++i)
		cout << s.FindSet(i) << "  ";
	cout << endl;
}