Пример #1
0
        public void DisjointSetAreEquivalentGuardCase4Test()
        {
            DisjointSet <int> disjointSet = new DisjointSet <int>();

            disjointSet.MakeSet(1);
            disjointSet.MakeSet(2);
            bool result = disjointSet.AreEquivalent(2, 5);
        }
Пример #2
0
        public void DisjointSetAreEquivalentGuardCase2Test()
        {
            DisjointSet <object> disjointSet = new DisjointSet <object>();

            disjointSet.MakeSet("item1");
            disjointSet.MakeSet("item2");
            bool result = disjointSet.AreEquivalent("item1", null);
        }
Пример #3
0
        public void DisjointSetAreEquivalentTest()
        {
            DisjointSet <int> disjointSet = new DisjointSet <int>();

            disjointSet.MakeSet(1);
            disjointSet.MakeSet(2);
            disjointSet.MakeSet(3);
            Assert.IsFalse(disjointSet.AreEquivalent(1, 2));
            Assert.IsFalse(disjointSet.AreEquivalent(2, 3));
            Assert.IsFalse(disjointSet.AreEquivalent(1, 3));
            disjointSet.Union(2, 3);
            Assert.IsFalse(disjointSet.AreEquivalent(1, 2));
            Assert.IsTrue(disjointSet.AreEquivalent(2, 3));
            Assert.IsFalse(disjointSet.AreEquivalent(1, 3));
        }