Exemplo n.º 1
0
        public static Graph ConstructKRegularGraph(int n, int k)  // n - liczba wierzcholkow,   k - liczba krawedzi jakie maja wychodzic z jednego wierzcholka
        {
            Graph      finalGraph = new Graph();
            List <int> GraphList  = new List <int>();

            for (int i = 0; i < n; ++i)
            {
                GraphList.Add(k);
            }

            if (GraphStringValidator.IsGraphString(GraphList))
            {
                finalGraph = GraphCreator.CreateGraphFromNodesDegrees(GraphList);
                if (k < 3)
                {
                    GraphCreator.RandomizeGraph(finalGraph, 1);  // With special thanks to P.Augustyn
                }
                else
                {
                    GraphCreator.RandomizeGraph(finalGraph, (k / 3));   // With special thanks to P.Augustyn
                }
            }

            return(finalGraph);
        }