Пример #1
0
        public static void ClassInit(TestContext context)
        {
            basicGraph = new Graph(9);
            basicGraph.AddEdge(0, 1);
            basicGraph.AddEdge(0, 2);
            basicGraph.AddEdge(0, 5);
            basicGraph.AddEdge(0, 6);
            basicGraph.AddEdge(2, 7);
            basicGraph.AddEdge(6, 4);
            basicGraph.AddEdge(4, 3);
            basicGraph.AddEdge(4, 5);

            baseicDigraph = new Digraph(7);
            baseicDigraph.AddEdge(5, 0);
            baseicDigraph.AddEdge(2, 4);
            baseicDigraph.AddEdge(3, 2);
            baseicDigraph.AddEdge(1, 2);
            baseicDigraph.AddEdge(0, 1);
            baseicDigraph.AddEdge(4, 3);
            baseicDigraph.AddEdge(3, 5);
            baseicDigraph.AddEdge(0, 2);
            baseicDigraph.AddEdge(6, 5);
        }
Пример #2
0
 public void Graph_API_Test()
 {
     Graph G = new Graph(3);
     G.AddEdge(0, 1);
     G.AddEdge(0, 2);
     List<int> e = new List<int>(G.Adj(0));
     Assert.AreEqual(1, e[0]);
 }
Пример #3
0
        public void Isomorphic_Test()
        {
            var G1 = new Graph(7);
            G1.AddEdge(0, 1);
            G1.AddEdge(0, 2);
            G1.AddEdge(0, 6);
            G1.AddEdge(0, 5);
            G1.AddEdge(4, 5);
            G1.AddEdge(4, 3);
            G1.AddEdge(4, 6);
            G1.AddEdge(3, 5);

            var G2 = new Graph(7);
            G2.AddEdge(4, 0);
            G2.AddEdge(4, 1);
            G2.AddEdge(4, 2);
            G2.AddEdge(4, 3);
            G2.AddEdge(5, 0);
            G2.AddEdge(5, 1);
            G2.AddEdge(5, 6);
            G2.AddEdge(0, 6);

            Assert.IsTrue(Isomorphic.IsIsomorphic(G1, G2));
            Assert.IsFalse(Isomorphic.IsIsomorphic(G1, basicGraph));
            Assert.IsFalse(Isomorphic.IsIsomorphic(G2, basicGraph));
        }
Пример #4
0
 public void Bipartite_Test()
 {
     var BG = new Graph(7);
     BG.AddEdge(0, 1);
     BG.AddEdge(0, 2);
     BG.AddEdge(0, 5);
     BG.AddEdge(0, 6);
     BG.AddEdge(2, 3);
     BG.AddEdge(2, 4);
     BG.AddEdge(1, 3);
     BG.AddEdge(4, 6);
     BG.AddEdge(4, 5);
     IEnumerable<int> G1;
     IEnumerable<int> G2;
     bool actual = BipartiteGraph.Depart(BG, out G1, out G2);
     Assert.IsTrue(actual);
 }