示例#1
0
        public void Reduce_LineGraph_NoSelftEdge()
        {
            var graphDict = new Dictionary<string, IEnumerable<string>>();
            graphDict.Add("a", new List<string> { "b" });
            graphDict.Add("b", new List<string> { });

            var reduced = graphDict.GetReduced("a'", "a");
            Assert.IsTrue(reduced.ContainsAllEdgesNot(Tuple.Create("b", "b")));
        }
示例#2
0
        public void Reduce_GroupOfOneVertex_NothingChanged()
        {
            var graphDict = new Dictionary<string, IEnumerable<string>>();
            graphDict.Add("a", new List<string> { "b", "c" });
            graphDict.Add("b", new List<string> { "c" });
            graphDict.Add("c", new List<string> { });

            var reduced = graphDict.GetReduced("a'", "a");
            Assert.IsTrue(reduced.ContainsAllVertices("a'", "b", "c"));
            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("a'", "b"), Tuple.Create("a'", "c"), Tuple.Create("b", "c")));
        }
示例#3
0
        public void Reduce_FourVerticesWithInsAndOuts_ConnectedLine()
        {
            var graphDict = new Dictionary<string, IEnumerable<string>>();
            graphDict.Add("a", new List<string> { "e" });
            graphDict.Add("b", new List<string> { });
            graphDict.Add("c", new List<string> { });
            graphDict.Add("d", new List<string> { });
            graphDict.Add("e", new List<string> { });
            graphDict.Add("f", new List<string> { "d" });

            var reduced = graphDict.GetReduced("abcd", "a", "b", "c", "d");
            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("abcd", "e"), Tuple.Create("f", "abcd")));
        }
示例#4
0
        public void Reduce_LineGraph_NoSelftEdge()
        {
            var graphDict = new Dictionary <string, IEnumerable <string> >();

            graphDict.Add("a", new List <string> {
                "b"
            });
            graphDict.Add("b", new List <string> {
            });

            var reduced = graphDict.GetReduced("a'", "a");

            Assert.IsTrue(reduced.ContainsAllEdgesNot(Tuple.Create("b", "b")));
        }
示例#5
0
        public void Reduce_LineGraph_SingleVertex()
        {
            var graphDict = new Dictionary <string, IEnumerable <string> >();

            graphDict.Add("a", new List <string> {
                "b"
            });
            graphDict.Add("b", new List <string> {
            });

            var reduced = graphDict.GetReduced("ab", "a", "b");

            Assert.IsTrue(reduced.ContainsAllVertices("ab"));
            Assert.IsTrue(reduced.ContainsAllVerticesNot("b"));
        }
示例#6
0
        public void Reduce_GroupOfNoVertices_NothingChanged()
        {
            var graphDict = new Dictionary <string, IEnumerable <string> >();

            graphDict.Add("a", new List <string> {
                "b", "c"
            });
            graphDict.Add("b", new List <string> {
                "c"
            });
            graphDict.Add("c", new List <string> {
            });

            var reduced = graphDict.GetReduced("-");

            Assert.IsTrue(reduced.ContainsAllVertices("a", "b", "c"));
            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("a", "b"), Tuple.Create("a", "c"), Tuple.Create("b", "c")));
        }
示例#7
0
        public void Reduce_ParallelLinesGraph_ParallelsConnected()
        {
            var graphDict = new Dictionary <string, IEnumerable <string> >();

            graphDict.Add("a", new List <string> {
                "b"
            });
            graphDict.Add("b", new List <string> {
            });
            graphDict.Add("c", new List <string> {
                "d"
            });
            graphDict.Add("d", new List <string> {
            });

            var reduced = graphDict.GetReduced("ac", "a", "c");

            Assert.IsTrue(reduced.ContainsAllVertices("ac", "b", "d"));
            Assert.IsTrue(reduced.ContainsAllVerticesNot("c"));
            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("ac", "b"), Tuple.Create("ac", "d")));
        }
示例#8
0
        public void Reduce_FourVerticesWithInsAndOuts_ConnectedLine()
        {
            var graphDict = new Dictionary <string, IEnumerable <string> >();

            graphDict.Add("a", new List <string> {
                "e"
            });
            graphDict.Add("b", new List <string> {
            });
            graphDict.Add("c", new List <string> {
            });
            graphDict.Add("d", new List <string> {
            });
            graphDict.Add("e", new List <string> {
            });
            graphDict.Add("f", new List <string> {
                "d"
            });

            var reduced = graphDict.GetReduced("abcd", "a", "b", "c", "d");

            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("abcd", "e"), Tuple.Create("f", "abcd")));
        }
示例#9
0
        public void Reduce_ParallelLinesGraph_ParallelsConnected()
        {
            var graphDict = new Dictionary<string, IEnumerable<string>>();
            graphDict.Add("a", new List<string> { "b" });
            graphDict.Add("b", new List<string> { });
            graphDict.Add("c", new List<string> { "d" });
            graphDict.Add("d", new List<string> { });

            var reduced = graphDict.GetReduced("ac", "a", "c");
            Assert.IsTrue(reduced.ContainsAllVertices("ac", "b", "d"));
            Assert.IsTrue(reduced.ContainsAllVerticesNot("c"));
            Assert.IsTrue(reduced.ContainsAllEdges(Tuple.Create("ac", "b"), Tuple.Create("ac", "d")));
        }
示例#10
0
        public void Reduce_LineGraph_SingleVertex()
        {
            var graphDict = new Dictionary<string, IEnumerable<string>>();
            graphDict.Add("a", new List<string> { "b" });
            graphDict.Add("b", new List<string> { });

            var reduced = graphDict.GetReduced("ab", "a", "b");
            Assert.IsTrue(reduced.ContainsAllVertices("ab"));
            Assert.IsTrue(reduced.ContainsAllVerticesNot("b"));
        }