Exemplo n.º 1
0
        public static DirectedGraphWithValuedEdgeAndPointID GenerateEmptyDirectedGraphWithValuedEdgeAndPointID(string GraphName, string PointNamePrefix, int PointCount)
        {
            DirectedGraphWithValuedEdgeAndPointID OutGraph = new DirectedGraphWithValuedEdgeAndPointID(GraphName, PointNamePrefix, new DirectedValuedEdgeEqualityComparer());

            for (int i = 1; i <= PointCount; i++)
            {
                OutGraph.AddPoint();
            }
            return(OutGraph);
        }
Exemplo n.º 2
0
        public static DirectedGraphWithValuedEdgeAndPointID GenerateRandomDirectedGraphWithValuedEdgeAndPointID(string GraphName, string PointNamePrefix, int PointCount, int EdgeCount)
        {
            if (EdgeCount > Math.Pow(PointCount, 2))
            {
                throw new Exception("Count of > PointCount^2");
            }

            DirectedGraphWithValuedEdgeAndPointID OutGraph = GenerateEmptyDirectedGraphWithValuedEdgeAndPointID(GraphName, PointNamePrefix, PointCount);

            List <PointWithID> ListPoints = OutGraph.PointCollection.ToList();

            for (int i = 1; i <= EdgeCount;)
            {
                if (OutGraph.AddEdge(new ValuedEdge <PointWithID>(GraphName + "_" + i.ToString(), ListPoints[GlobalRandom.Next(0, ListPoints.Count)], ListPoints[GlobalRandom.Next(0, ListPoints.Count)], GlobalRandom.NextDouble() + GlobalRandom.Next(1, 10))))
                {
                    i++;
                }
            }

            return(OutGraph);
        }