c++,algorithm,data-structures,disjoint-sets,disjoint-union

In your Union function, check if both nodes are already in the same set. if(xNode && yNode && xNode != yNode) link(xNode,yNode); ...

c++,algorithm,data-structures,disjoint-sets,disjoint-union

Each union operaiton on two items a,b in Disjoint Set Data Structure has two possible scenarios: You tried to unite items from the same set. In this case, nothing is done, and number of disjoint sets remain the same. You united items from two different sets, so you basically converged...

constructor,agda,theorem-proving,disjoint-union

The data type constructors are disjoint. I'd say it's a theorem in Agda's type-system meta-theory. You can try to case the eq proof (C-c C-c), and Agda will find the contradiction: lemma : ∀ {a b} {A : Set a} {B : Set b} {x : A} {y : B}...