Пример #1
0
        /// <summary>
        /// Generates a simple random network with n nodes and m edges
        /// </summary>
        /// <param name="n">The number of nodes</param>
        /// <param name="m">The number of edges</param>
        /// <returns>A random network</returns>
        public static SimpleNetwork CreateRandomNetwork(int n, int m)
        {
            Random r = new Random();
            SimpleNetwork net = new SimpleNetwork();

            for(int i = 0; i<n; i++)
                net.AddVertex(i.ToString());

            for (int j = 0; j < m; j++)
                {
                    string x = net.GetVertexArray()[r.Next(net.GetVertexCount())];
                    string y = net.GetVertexArray()[r.Next(net.GetVertexCount())];
                    net.AddEdge(x, y);
                }
            return net;
        }
Пример #2
0
        /// <summary>
        /// Generates a simple random network with n nodes and m edges
        /// </summary>
        /// <param name="n">The number of nodes</param>
        /// <param name="m">The number of edges</param>
        /// <returns>A random network</returns>
        public static SimpleNetwork CreateRandomNetwork(int n, int m)
        {
            Random        r   = new Random();
            SimpleNetwork net = new SimpleNetwork();

            for (int i = 0; i < n; i++)
            {
                net.AddVertex(i.ToString());
            }

            for (int j = 0; j < m; j++)
            {
                string x = net.GetVertexArray()[r.Next(net.GetVertexCount())];
                string y = net.GetVertexArray()[r.Next(net.GetVertexCount())];
                net.AddEdge(x, y);
            }
            return(net);
        }