示例#1
0
        public static void TestIsTheSameGraph()
        {
            var graph = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root
            });

            var tour = EulerGraph <string> .MakeTour(graph, "a");

            graph.Tours.Add(tour);
            var expected = new List <string> {
                "a", "c", "e", "c", "d", "f", "d", "b", "d", "c", "a"
            };

            CollectionAssert.AreEquivalent(expected, tour);

            var graph2 = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root2
            });

            var tour2 = EulerGraph <string> .MakeTour(graph2, "g");

            graph2.Tours.Add(tour2);
            var expected2 = new List <string> {
                "g", "h", "g", "j", "k", "j", "i", "j", "g"
            };

            CollectionAssert.AreEquivalent(expected2, tour2);

            Assert.IsTrue(graph.BothBelong("f", "e"));
            Assert.IsFalse(graph.BothBelong("f", "g"));
            Assert.IsTrue(graph2.BothBelong("j", "i"));
            Assert.IsFalse(graph2.BothBelong("f", "i"));
        }
示例#2
0
        public static void TestMakeTourFromGraph()
        {
            var graph = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root
            });

            var tour = EulerGraph <string> .MakeTour(graph, graph.Roots[0]);

            graph.Tours.Add(tour);

            var expected = new List <string> {
                "a", "c", "e", "c", "d", "f", "d", "b", "d", "c", "a"
            };

            CollectionAssert.AreEquivalent(expected, tour);
        }
示例#3
0
        public static void TestChangeGraphRoot()
        {
            var graph = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root
            });

            var tour = EulerGraph <string> .MakeTour(graph, "a");

            var expected = new List <string> {
                "a", "c", "e", "c", "d", "f", "d", "b", "d", "c", "a"
            };

            CollectionAssert.AreEquivalent(expected, tour);

            tour = EulerGraph <string> .MakeTour(graph, "d");

            expected = new List <string> {
                "d", "f", "d", "b", "d", "c", "e", "c", "a", "c", "d"
            };
            CollectionAssert.AreEquivalent(expected, tour);
        }
示例#4
0
        public static void TestAddEdgeForTwoGraph()
        {
            var graph = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root
            });

            var tour = EulerGraph <string> .MakeTour(graph, "a");

            graph.Tours.Add(tour);
            var expected = new List <string> {
                "a", "c", "e", "c", "d", "f", "d", "b", "d", "c", "a"
            };

            CollectionAssert.AreEquivalent(expected, tour);

            var graph2 = EulerGraph <string> .MakeGraph(new List <EulerNode <string> > {
                Root2
            });

            var tour2 = EulerGraph <string> .MakeTour(graph2, "g");

            graph2.Tours.Add(tour2);
            var expected2 = new List <string> {
                "g", "h", "g", "j", "k", "j", "i", "j", "g"
            };

            CollectionAssert.AreEquivalent(expected2, tour2);

            var mergedGraph = EulerGraph <string> .Merge(graph, graph2);

            var expected3 = new List <string> {
                "a", "c", "e", "c", "d", "f", "d", "b", "d", "c", "a", "g", "h", "g", "j", "k", "j", "i", "j", "g", "a"
            };

            CollectionAssert.AreEquivalent(expected3, mergedGraph.Tours[0]);
        }