Analyzer.ClusteringCoefficientCalculator.TryCalculateGraphMetrics C# (CSharp) Method

TryCalculateGraphMetrics() public method

public TryCalculateGraphMetrics ( IGraph graph, BackgroundWorker backgroundWorker, MetricDouble &graphMetrics ) : bool
graph IGraph
backgroundWorker System.ComponentModel.BackgroundWorker
graphMetrics MetricDouble
return bool
        public bool TryCalculateGraphMetrics
            (IGraph graph, BackgroundWorker backgroundWorker, out MetricDouble graphMetrics)
        {
            Debug.Assert(graph != null);

            IVertexCollection oVertices = graph.Vertices;
            Int32 iVertices = oVertices.Count;

            MetricDouble oClusteringCoefficients = new MetricDouble(iVertices, "ClusteringCoefficient");
            graphMetrics = oClusteringCoefficients;

            bool bGraphIsDirected = (graph.Directedness == GraphDirectedness.Directed);

            Int32 iCalculations = 0;

            foreach (IVertex oVertex in oVertices)
            {
                if (iCalculations % VerticesPerProgressReport == 0 &&
                    !ReportProgressAndCheckCancellationPending(iCalculations, iVertices, backgroundWorker))
                {
                    return (false);
                }

                oClusteringCoefficients.Add(oVertex.ID, CalculateClusteringCoefficient(oVertex, bGraphIsDirected));

                iCalculations++;
            }

            return (true);
        }