Exemple #1
0
        public static DirectedGraphWithPointID GenerateEmptyDirectedGraphWithPointID(string GraphName, string PointNamePrefix, int PointCount)
        {
            DirectedGraphWithPointID OutGraph = new DirectedGraphWithPointID(GraphName, PointNamePrefix, new AbstractEdgeEqualityComparer <PointWithID>());

            for (int i = 1; i <= PointCount; i++)
            {
                OutGraph.AddPoint();
            }
            return(OutGraph);
        }
Exemple #2
0
        public static DirectedGraphWithPointID GetSpanningSubgraph(DirectedGraphWithPointID CurrentGraph, SelectionCondition <EdgePointID> EdgeSelectionCondition)
        {
            DirectedGraphWithPointID OutGraph = new DirectedGraphWithPointID(String.Format("Spanning \"{0}\"", CurrentGraph.GraphName), CurrentGraph.PointNamePrefix, new AbstractEdgeEqualityComparer <PointWithID>());

            IEnumerable <EdgePointID> edgeCollection = CurrentGraph.EdgeCollection.Where(i1 => EdgeSelectionCondition(i1));

            foreach (PointWithID p in CurrentGraph.PointCollection)
            {
                OutGraph.AddPoint(p);
            }
            foreach (EdgePointID e in edgeCollection)
            {
                OutGraph.AddEdge(e);
            }

            return(OutGraph);
        }
Exemple #3
0
        public static DirectedGraphWithPointID GetInducedSubgraph(DirectedGraphWithPointID CurrentGraph, IEnumerable <Point> PointCollection)
        {
            DirectedGraphWithPointID OutGraph = new DirectedGraphWithPointID(String.Format("Induced \"{0}\"", CurrentGraph.GraphName), CurrentGraph.PointNamePrefix, new AbstractEdgeEqualityComparer <PointWithID>());

            IEnumerable <EdgePointID> edgeCollection = CurrentGraph.EdgeCollection.Where(i1 => PointCollection.Contains(i1.StartPoint) && PointCollection.Contains(i1.EndPoint));

            foreach (PointWithID p in PointCollection)
            {
                OutGraph.AddPoint(p);
            }
            foreach (EdgePointID e in edgeCollection)
            {
                OutGraph.AddEdge(e);
            }

            return(OutGraph);
        }
Exemple #4
0
        public static DirectedGraphWithPointID GenerateRandomDirectedGraphWithPointID(string GraphName, string PointNamePrefix, int PointCount, int EdgeCount)
        {
            if (EdgeCount > Math.Pow(PointCount, 2))
            {
                throw new Exception("Count of > PointCount^2");
            }

            DirectedGraphWithPointID OutGraph = GenerateEmptyDirectedGraphWithPointID(GraphName, PointNamePrefix, PointCount);

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

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

            return(OutGraph);
        }
Exemple #5
0
        public static DirectedGraphWithPointID GetInducedSubgraph(DirectedGraphWithPointID CurrentGraph, SelectionCondition <PointWithID> PointSelectionCondition)
        {
            IEnumerable <PointWithID> pointCollection = CurrentGraph.PointCollection.Where(i1 => PointSelectionCondition(i1));

            return(GetInducedSubgraph(CurrentGraph, pointCollection));
        }