コード例 #1
0
 //*************************************************************************
 //  Constructor: ConnectedComponentCalculatorTest()
 //
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="ConnectedComponentCalculatorTest" /> class.
 /// </summary>
 //*************************************************************************
 public ConnectedComponentCalculatorTest()
 {
     m_oConnectedComponentCalculator = null;
     m_oGraph = null;
     m_oVertices = null;
     m_oEdges = null;
 }
コード例 #2
0
 public void SetUp()
 {
     m_oConnectedComponentCalculator = new ConnectedComponentCalculator();
     m_oGraph = new Graph();
     m_oVertices = m_oGraph.Vertices;
     m_oEdges = m_oGraph.Edges;
 }
コード例 #3
0
        CalculateConnectedComponentMetrics
        (
            IGraph oGraph,
            out Int32 iConnectedComponents,
            out Int32 iSingleVertexConnectedComponents,
            out Int32 iMaximumConnectedComponentVertices,
            out Int32 iMaximumConnectedComponentEdges
        )
        {
            Debug.Assert(oGraph != null);
            AssertValid();

            ConnectedComponentCalculator oConnectedComponentCalculator =
                new ConnectedComponentCalculator();

            IList <LinkedList <IVertex> > oConnectedComponents =
                oConnectedComponentCalculator.CalculateStronglyConnectedComponents(
                    oGraph, true);

            iConnectedComponents               = oConnectedComponents.Count;
            iSingleVertexConnectedComponents   = 0;
            iMaximumConnectedComponentVertices = 0;
            iMaximumConnectedComponentEdges    = 0;

            foreach (LinkedList <IVertex> oConnectedComponent in
                     oConnectedComponents)
            {
                Int32 iVertices = oConnectedComponent.Count;

                if (iVertices == 1)
                {
                    iSingleVertexConnectedComponents++;
                }

                iMaximumConnectedComponentVertices = Math.Max(
                    iMaximumConnectedComponentVertices, iVertices);

                iMaximumConnectedComponentEdges = Math.Max(
                    iMaximumConnectedComponentEdges,
                    CountUniqueEdges(oConnectedComponent));
            }
        }
コード例 #4
0
        //*************************************************************************
        //  Method: CalculateConnectedComponentMetrics()
        //
        /// <summary>
        /// Calculates the graph's connected component metrics.
        /// </summary>
        ///
        /// <param name="oGraph">
        /// The graph to calculate metrics for.
        /// </param>
        ///
        /// <param name="iConnectedComponents">
        /// Where the number of connected components in the graph gets stored.
        /// </param>
        ///
        /// <param name="iSingleVertexConnectedComponents">
        /// Where the number of connected components in the graph that have one
        /// vertex gets stored.
        /// </param>
        ///
        /// <param name="iMaximumConnectedComponentVertices">
        /// Where the maximum number of vertices in a connected component gets
        /// stored.
        /// </param>
        ///
        /// <param name="iMaximumConnectedComponentEdges">
        /// Where the maximum number of edges in a connected component gets stored.
        /// </param>
        //*************************************************************************
        protected void CalculateConnectedComponentMetrics(
            IGraph oGraph,
            out Int32 iConnectedComponents,
            out Int32 iSingleVertexConnectedComponents,
            out Int32 iMaximumConnectedComponentVertices,
            out Int32 iMaximumConnectedComponentEdges
            )
        {
            Debug.Assert(oGraph != null);
            AssertValid();

            ConnectedComponentCalculator oConnectedComponentCalculator =
            new ConnectedComponentCalculator();

            IList< LinkedList<IVertex> > oConnectedComponents =
            oConnectedComponentCalculator.CalculateStronglyConnectedComponents(
                oGraph, true);

            iConnectedComponents = oConnectedComponents.Count;
            iSingleVertexConnectedComponents = 0;
            iMaximumConnectedComponentVertices = 0;
            iMaximumConnectedComponentEdges = 0;

            foreach (LinkedList<IVertex> oConnectedComponent in
            oConnectedComponents)
            {
            Int32 iVertices = oConnectedComponent.Count;

            if (iVertices == 1)
            {
                iSingleVertexConnectedComponents++;
            }

            iMaximumConnectedComponentVertices = Math.Max(
                iMaximumConnectedComponentVertices, iVertices);

            iMaximumConnectedComponentEdges = Math.Max(
                iMaximumConnectedComponentEdges,
                CountUniqueEdges(oConnectedComponent) );
            }
        }
コード例 #5
0
 public void TearDown()
 {
     m_oConnectedComponentCalculator = null;
     m_oGraph = null;
     m_oVertices = null;
     m_oEdges = null;
 }