CalculateStronglyConnectedComponents() public method

public CalculateStronglyConnectedComponents ( ICollection vertices, IGraph graph, System.Boolean sortAscending ) : IList>
vertices ICollection
graph IGraph
sortAscending System.Boolean
return IList>
        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));
            }
        }
    LayOutSmallerComponentsInBins
    (
        IGraph graph,
        ICollection<IVertex> verticesToLayOut,
        LayoutContext layoutContext,
        out ICollection<IVertex> remainingVertices,
        out Rectangle remainingRectangle
    )
    {
        AssertValid();

        remainingVertices = null;
        remainingRectangle = Rectangle.Empty;

        // This method modifies some of the graph's metadata.  Save the
        // original metadata.

        Boolean bOriginalGraphHasBeenLaidOut =
            LayoutMetadataUtil.GraphHasBeenLaidOut(graph);

        ICollection<IVertex> oOriginalLayOutTheseVerticesOnly =
            ( ICollection<IVertex> )graph.GetValue(
                ReservedMetadataKeys.LayOutTheseVerticesOnly,
                typeof( ICollection<IVertex> ) );

        // Split the vertices into strongly connected components, sorted in
        // increasing order of vertex count.

        ConnectedComponentCalculator oConnectedComponentCalculator =
            new ConnectedComponentCalculator();

        IList< LinkedList<IVertex> > oComponents =
            oConnectedComponentCalculator.CalculateStronglyConnectedComponents(
                verticesToLayOut, graph, true);

        Int32 iComponents = oComponents.Count;

        // This object will split the graph rectangle into bin rectangles.

        RectangleBinner oRectangleBinner = new RectangleBinner(
            layoutContext.GraphRectangle, m_iBinLength);

        Int32 iComponent = 0;

        for (iComponent = 0; iComponent < iComponents; iComponent++)
        {
            LinkedList<IVertex> oComponent = oComponents[iComponent];
            Int32 iVerticesInComponent = oComponent.Count;

            if (iVerticesInComponent> m_iMaximumVerticesPerBin)
            {
                // The vertices in the remaining components should not be
                // binned.

                break;
            }

            Rectangle oBinRectangle;

            if ( !oRectangleBinner.TryGetNextBin(out oBinRectangle) )
            {
                // There is no room for an additional bin rectangle.

                break;
            }

            // Lay out the component within the bin rectangle.

            LayOutComponentInBin(graph, oComponent, oBinRectangle);
        }

        // Restore the original metadata on the graph.

        if (bOriginalGraphHasBeenLaidOut)
        {
            LayoutMetadataUtil.MarkGraphAsLaidOut(graph);
        }
        else
        {
            LayoutMetadataUtil.MarkGraphAsNotLaidOut(graph);
        }

        if (oOriginalLayOutTheseVerticesOnly != null)
        {
            graph.SetValue(ReservedMetadataKeys.LayOutTheseVerticesOnly,
                oOriginalLayOutTheseVerticesOnly);
        }
        else
        {
            graph.RemoveKey(ReservedMetadataKeys.LayOutTheseVerticesOnly);
        }

        if ( oRectangleBinner.TryGetRemainingRectangle(
            out remainingRectangle) )
        {
            remainingVertices = GetRemainingVertices(oComponents, iComponent);

            return (remainingVertices.Count > 0);
        }

        return (false);
    }
    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) );
        }
    }