Exemple #1
0
        public void ListInOrder2()
        {
            DataGraph <string> g = new DataGraph <string>();
            uint n0 = g.AddNode("0");
            uint n1 = g.AddNode("1");
            uint n2 = g.AddNode("2");
            uint n3 = g.AddNode("3");
            uint n4 = g.AddNode("4");
            uint n5 = g.AddNode("5");
            uint n6 = g.AddNode("6");
            uint n7 = g.AddNode("7");

            g.LinkDirectional(n0, n1);
            g.LinkDirectional(n0, n5);
            g.LinkDirectional(n0, n3);
            g.LinkDirectional(n1, n2);
            g.LinkDirectional(n1, n4);
            g.LinkDirectional(n2, n3);
            g.LinkDirectional(n5, n6);
            g.LinkDirectional(n5, n7);
            g.LinkDirectional(n6, n3);

            // We perform analysis.
            List <uint> r = GraphAnalysis.ListNodesInOrder(n0, g);


            Assert.AreEqual(8, r.Count);
        }
Exemple #2
0
        public void FindSimple()
        {
            DataGraph <string> g = new DataGraph <string>();

            g.AddNode("A");
            g.AddNode("B");
            g.AddNode("C");
            g.AddNode("D");
            g.AddNode("E");
            g.AddNode("F");
            g.Link(0, 1);
            g.Link(0, 4);
            g.Link(1, 2);
            g.Link(2, 3);
            g.Link(1, 3);
            g.Link(4, 5);

            BFS search = new BFS(g, 0, 3);

            search.Search();

            // We find solutions.
            SearchResult[] results = search.Results;
            Assert.AreEqual(1, results.Length);

            Assert.IsTrue(results[0].Equals(new SearchResult(0, 1, 3)));
        }