Example #1
0
        private (Graph, Graph) RandomTest(Random r, int n, int maxLvlSize)
        {
            Graph t = new AdjacencyListsGraph <SimpleAdjacencyList>(false, n);
            Graph g = new AdjacencyListsGraph <AVLAdjacencyList>(false, n);
            int   minLvl = 0, maxLvl = 0;

            while (maxLvl < n - 1)
            {
                int lvlCnt = r.Next(1, Math.Min(maxLvlSize, n - maxLvl - 1));
                for (int i = 0; i < lvlCnt; ++i)
                {
                    int parent = r.Next(minLvl, maxLvl);
                    t.AddEdge(parent, maxLvl + i + 1);
                    g.AddEdge(parent, maxLvl + i + 1);
                    for (int j = 0; j < i; ++j)
                    {
                        if (r.Next(0, 2) == 1)
                        {
                            g.AddEdge(maxLvl + i + 1, maxLvl + j + 1);
                        }
                    }
                }
                minLvl = maxLvl + 1;
                maxLvl = maxLvl + lvlCnt;
            }
            return(g, t);
        }
Example #2
0
        //3 cykle
        private (Graph g, Graph t) Test02()
        {
            Graph t = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 5);

            t.AddEdge(0, 1);
            t.AddEdge(0, 2);
            t.AddEdge(0, 3);
            t.AddEdge(0, 4);
            Graph g = new AdjacencyListsGraph <HashTableAdjacencyList>(t);

            g.AddEdge(1, 3);
            g.AddEdge(1, 4);
            g.AddEdge(1, 2);
            return(g, t);
        }
Example #3
0
        //drzewo
        private (Graph g, Graph t) Test03()
        {
            Graph t = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 10);

            t.AddEdge(0, 1);
            t.AddEdge(0, 2);
            t.AddEdge(0, 8);
            t.AddEdge(1, 9);
            t.AddEdge(1, 3);
            t.AddEdge(2, 4);
            t.AddEdge(2, 6);
            t.AddEdge(6, 7);
            t.AddEdge(4, 5);
            return(t.Clone(), t);
        }
Example #4
0
        private (Graph, Graph) FullGraph(RandomGraphGenerator rgg, int n)
        {
            Graph g = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), n, 1);
            Graph t = new AdjacencyListsGraph <SimpleAdjacencyList>(false, n);

            for (int i = 1; i < n; ++i)
            {
                t.AddEdge(0, i);
            }
            return(g, t);
        }
Example #5
0
        //głębokie drzewo
        private (Graph, Graph) Test05()
        {
            Graph t = new AdjacencyListsGraph <AVLAdjacencyList>(false, 16);

            t.AddEdge(0, 3);
            t.AddEdge(3, 5);
            t.AddEdge(5, 1);
            t.AddEdge(1, 6);
            t.AddEdge(6, 11);
            t.AddEdge(0, 7);
            t.AddEdge(7, 10);
            t.AddEdge(10, 15);
            t.AddEdge(10, 4);
            t.AddEdge(4, 8);
            t.AddEdge(0, 12);
            t.AddEdge(12, 13);
            t.AddEdge(13, 2);
            t.AddEdge(2, 9);
            t.AddEdge(9, 14);
            Graph g = t.Clone();

            g.AddEdge(3, 12);
            g.AddEdge(5, 7);
            g.AddEdge(10, 13);
            g.AddEdge(4, 13);
            g.AddEdge(1, 4);
            g.AddEdge(4, 2);
            return(g, t);
        }