public void UnionFindNode_MergeTwo() { UnionFindNode <string> nodeA = CreateStringNode("A"); UnionFindNode <string> nodeB = CreateStringNode("B"); UnionFindNode <string> .Merge(nodeA, nodeB); Assert.AreEqual(nodeB.Label, nodeA.FindSet()); }
public void UnionFindNode_MergeThree_Chained() { UnionFindNode <string> nodeA = CreateStringNode("A"); UnionFindNode <string> nodeB = CreateStringNode("B"); UnionFindNode <string> nodeC = CreateStringNode("C"); UnionFindNode <string> .Merge(nodeA, nodeB); UnionFindNode <string> .Merge(nodeB, nodeC); Assert.AreEqual(nodeC.Label, nodeA.FindSet()); Assert.AreEqual(nodeC.Label, nodeB.FindSet()); Assert.AreEqual(nodeC.Label, nodeC.FindSet()); }
public void UnionFindNode_MergeFour_TwoSets() { UnionFindNode <string> nodeA = CreateStringNode("A"); UnionFindNode <string> nodeB = CreateStringNode("B"); UnionFindNode <string> nodeC = CreateStringNode("C"); UnionFindNode <string> nodeD = CreateStringNode("D"); UnionFindNode <string> .Merge(nodeA, nodeB); UnionFindNode <string> .Merge(nodeC, nodeD); UnionFindNode <string> .Merge(nodeB, nodeD); Assert.AreEqual(nodeD.Label, nodeA.FindSet()); Assert.AreEqual(nodeD.Label, nodeB.FindSet()); Assert.AreEqual(nodeD.Label, nodeC.FindSet()); Assert.AreEqual(nodeD.Label, nodeD.FindSet()); }