[FIX] Fixing connectedComponents().

Use standard Union-Find data structure instead of traversal algorithm that appears to be non-working anyway.