Analyzer.DConnectorMotifDetector.TryCalculateDConnectorMotifs C# (CSharp) Method

TryCalculateDConnectorMotifs() public method

public TryCalculateDConnectorMotifs ( IGraph oGraph, Int32 iDMinimum, Int32 iDMaximum, BackgroundWorker oBackgroundWorker, ICollection &oMotifs ) : System.Boolean
oGraph IGraph
iDMinimum System.Int32
iDMaximum System.Int32
oBackgroundWorker System.ComponentModel.BackgroundWorker
oMotifs ICollection
return System.Boolean
        public Boolean TryCalculateDConnectorMotifs
            (IGraph oGraph, Int32 iDMinimum, Int32 iDMaximum, BackgroundWorker oBackgroundWorker, out ICollection<Motif> oMotifs)
        {
            Debug.Assert(oGraph != null);

            oMotifs = null;

            IVertexCollection oVertices = oGraph.Vertices;
            Int32 iVertices = oVertices.Count;
            Int32 iCalculationsSoFar = 0;

            // The key is an ordered combination of the vertex IDs of the potential
            // motif's D anchor vertices, and the value is the corresponding
            // potential DConnectorMotif object.

            Dictionary<string, DConnectorMotif> oPotentialDConnectorMotifs =
                new Dictionary<string, DConnectorMotif>();

            foreach (IVertex oPotentialSpanVertex in oVertices)
            {
                
                if ((iCalculationsSoFar % 100 == 0)
                 &&
                 !ReportProgressAndCheckCancellationPending(
                     iCalculationsSoFar, iVertices, oBackgroundWorker))
                {
                    return (false);
                }

                // Get only the non-self-loop adjacent vertices
                ICollection<IVertex> oPotentialAnchorVertices =
                    oPotentialSpanVertex.AdjacentVertices
                    .Where<IVertex>(adjVertex => adjVertex != oPotentialSpanVertex).ToList<IVertex>();

                if (DVerticesMightBeAnchors(oPotentialAnchorVertices, iDMinimum, iDMaximum))
                {
                    AddSpanVertexToPotentialDConnectorMotifs(
                        oPotentialSpanVertex, oPotentialAnchorVertices,
                        oPotentialDConnectorMotifs);
                }

                iCalculationsSoFar++;
            }

            // Filter the potential D-connector motifs and add the real ones to
            // the collection of motifs.

            oMotifs = FilterDConnectorMotifs(oPotentialDConnectorMotifs);

            // Set the SpanScale property on each DConnectorMotif object.

            SetDConnectorMotifSpanScale(oMotifs);

            return (true);
        }