Inheritance: CmisSync.Lib.Algorithms.AbstractTarjanNode
        public void LargerSimpleCycleWithBlindEnd2()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B", a);
            var c = new StringTarjanNode("C", b);
            var d = new StringTarjanNode("D", c);

            a.Neighbors.Add(d);

            var e = new StringTarjanNode("E", c);

            var underTest = new Tarjan(a, b, c, d, e);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(2));
            var first = underTest.ResultSets.First();
            var last  = underTest.ResultSets.Last();
            var large = first.Count > last.Count ? first : last;
            var small = first.Count > last.Count ? last : first;

            Assert.That(large.Count == 4);
            Assert.That(small.Count == 1);
            Assert.That(large.Contains(a));
            Assert.That(large.Contains(b));
            Assert.That(large.Contains(c));
            Assert.That(large.Contains(d));
            Assert.That(small.Contains(e));
        }
        public void TwoNodes()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B");
            a.Neighbors.Add(b);

            var underTest = new Tarjan(a, b);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(2));
        }
Ejemplo n.º 3
0
        public void TwoNodes()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B");

            a.Neighbors.Add(b);

            var underTest = new Tarjan(a, b);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(2));
        }
        public void SimpleCycle()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B", a);
            a.Neighbors.Add(b);

            var underTest = new Tarjan(a, b);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(1));
            Assert.That(underTest.ResultSets.First().Contains(a));
            Assert.That(underTest.ResultSets.First().Contains(b));
        }
        public void SimpleCycle()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B", a);

            a.Neighbors.Add(b);

            var underTest = new Tarjan(a, b);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(1));
            Assert.That(underTest.ResultSets.First().Contains(a));
            Assert.That(underTest.ResultSets.First().Contains(b));
        }
        public void FourNodes()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B");
            var c = new StringTarjanNode("C");
            var d = new StringTarjanNode("D");
            a.Neighbors.Add(b);
            b.Neighbors.Add(c);
            c.Neighbors.Add(d);

            var underTest = new Tarjan(a, b, c, d);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(4));
        }
Ejemplo n.º 7
0
        public void FourTreeNodes()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B");
            var c = new StringTarjanNode("C");
            var d = new StringTarjanNode("D");

            a.Neighbors.Add(b);
            b.Neighbors.Add(c);
            b.Neighbors.Add(d);

            var underTest = new Tarjan(a, b, c, d);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(4));
        }
Ejemplo n.º 8
0
        public void TwoIndepdendedChainsOfTwoNodes()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B");

            a.Neighbors.Add(b);

            var c = new StringTarjanNode("C");
            var d = new StringTarjanNode("D");

            c.Neighbors.Add(d);

            var underTest = new Tarjan(a, b, c, d);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(4));
        }
        public void TwoCycles()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B", a);

            a.Neighbors.Add(b);

            var c = new StringTarjanNode("C");
            var d = new StringTarjanNode("D", c);

            c.Neighbors.Add(d);

            var underTest = new Tarjan(a, b, c, d);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(2));
        }
        public void LargerSimpleCycleWithBlindEnd()
        {
            var a = new StringTarjanNode("A");
            var b = new StringTarjanNode("B", a);
            var c = new StringTarjanNode("C", b);
            var d = new StringTarjanNode("D", c);
            a.Neighbors.Add(d);

            var e = new StringTarjanNode("E");
            c.Neighbors.Add(e);

            var underTest = new Tarjan(a, b, c, d, e);

            Assert.That(underTest.ResultSets.Count, Is.EqualTo(2));
            var first = underTest.ResultSets.First();
            var last = underTest.ResultSets.Last();
            var large = first.Count > last.Count ? first : last;
            var small = first.Count > last.Count ? last : first;
            Assert.That(large.Count == 4);
            Assert.That(small.Count == 1);
            Assert.That(large.Contains(a));
            Assert.That(large.Contains(b));
            Assert.That(large.Contains(c));
            Assert.That(large.Contains(d));
            Assert.That(small.Contains(e));
        }