Analyzer.FanMotifDetector.TryCalculateFanMotif C# (CSharp) Method

TryCalculateFanMotif() public method

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

            oMotifs = null;

            LinkedList<Motif> oFanMotifs = new LinkedList<Motif>();
            LinkedList<IVertex> oLeaves = new LinkedList<IVertex>();

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

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

                ICollection<IVertex> oAdjacentVertices = oVertex.AdjacentVertices;

                if (oAdjacentVertices.Count >= 2)
                {
                    foreach (IVertex oAdjacentVertex in oAdjacentVertices)
                    {
                        if (oAdjacentVertex.AdjacentVertices.Count == 1)
                        {
                            oLeaves.AddLast(oAdjacentVertex);
                        }
                    }

                    if (oLeaves.Count >= 2)
                    {
                        oFanMotifs.AddLast(
                            new FanMotif(oVertex, oLeaves.ToArray()));
                    }

                    oLeaves.Clear();
                }

                iCalculationsSoFar++;
            }

            // Set the ArcScale property on each FanMotif object.

            SetFanMotifArcScale(oFanMotifs);

            oMotifs = oFanMotifs;

            return (true);
        }