Example #1
0
        TryCalculateGraphMetricsForOneGroup
        (
            GroupInformation oGroupInformation,
            CalculateGraphMetricsContext oCalculateGraphMetricsContext,
            out OverallMetrics oOverallMetrics
        )
        {
            Debug.Assert(oGroupInformation != null);
            Debug.Assert(oGroupInformation.Vertices != null);
            Debug.Assert(oGroupInformation.Vertices.Count > 0);
            Debug.Assert(oCalculateGraphMetricsContext != null);
            AssertValid();

            oOverallMetrics = null;

            ICollection <IVertex> oVertices = oGroupInformation.Vertices;

            // Create a new graph from the vertices in the group and the edges that
            // connect them.

            IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(oVertices);

            // Calculate the overall metrics for the new graph using the
            // OverallMetricCalculator class in the Algorithms namespace, which
            // knows nothing about Excel.

            return((new Algorithms.OverallMetricCalculator()).
                   TryCalculateGraphMetrics(oNewGraph,
                                            oCalculateGraphMetricsContext.BackgroundWorker,
                                            out oOverallMetrics));
        }
Example #2
0
        TestGetSubgraphAsNewGraph9()
        {
            // Complete graph, include two vertices.

            foreach (Boolean bDirected in TestGraphUtil.AllBoolean)
            {
                CreateGraph(bDirected);

                Dictionary <String, IVertex> oVertexDictionary = AddVertices(
                    "A", "B", "C", "D"
                    );

                AddEdgesForCompleteGraph(oVertexDictionary);

                IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(
                    new IVertex[] {
                    oVertexDictionary["A"],
                    oVertexDictionary["B"],
                });

                CheckVertices(oNewGraph, "A", "B");

                CheckEdges(oNewGraph,
                           "A", "A",
                           "A", "B",
                           "B", "B",
                           "B", "A"
                           );
            }
        }
Example #3
0
        TestGetSubgraphAsNewGraph7()
        {
            // Include two vertices, with edges that are included, undirected
            // graph.

            CreateGraph(false);

            Dictionary <String, IVertex> oVertexDictionary = AddVertices(
                "A", "B"
                );

            AddEdges(oVertexDictionary,
                     "A", "B",
                     "A", "B",
                     "B", "A",
                     "B", "A"
                     );

            IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(
                new IVertex[] {
                oVertexDictionary["A"],
                oVertexDictionary["B"]
            });

            CheckVertices(oNewGraph, "A", "B");

            CheckEdges(oNewGraph,
                       "A", "B",
                       "A", "B",
                       "B", "A",
                       "B", "A"
                       );
        }
Example #4
0
        TestGetSubgraphAsNewGraph6()
        {
            CreateGraph(true);

            // Inclue two vertices, with edges that are included.

            Dictionary <String, IVertex> oVertexDictionary = AddVertices(
                "A", "B"
                );

            AddEdges(oVertexDictionary,
                     "A", "B",
                     "A", "B",
                     "B", "A",
                     "B", "A"
                     );

            IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(
                new IVertex[] {
                oVertexDictionary["A"],
                oVertexDictionary["B"]
            });

            CheckVertices(oNewGraph, "A", "B");

            CheckEdges(oNewGraph,
                       "A", "B",
                       "A", "B",
                       "B", "A",
                       "B", "A"
                       );
        }
Example #5
0
        TestGetSubgraphAsNewGraph()
        {
            // Include one vertex, no edges.

            CreateGraph(true);

            Dictionary <String, IVertex> oVertexDictionary = AddVertices(
                "A"
                );

            IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(
                new IVertex[] { oVertexDictionary["A"] });

            CheckVertices(oNewGraph, "A");
            CheckEdges(oNewGraph);
        }
Example #6
0
        TestGetSubgraphAsNewGraph3()
        {
            // Include one vertex, with self-loop edge that is included.

            CreateGraph(true);

            Dictionary <String, IVertex> oVertexDictionary = AddVertices(
                "A"
                );

            AddEdges(oVertexDictionary, "A", "A");

            IGraph oNewGraph = SubgraphCalculator.GetSubgraphAsNewGraph(
                new IVertex[] { oVertexDictionary["A"] });

            CheckVertices(oNewGraph, "A");
            CheckEdges(oNewGraph, "A", "A");
        }