public Boolean TryCalculateGraphMetrics
(IGraph graph, BackgroundWorker backgroundWorker, out VertexMetricBase graphMetrics)
{
Debug.Assert(graph != null);
IVertexCollection oVertices = graph.Vertices;
Int32 iVertices = oVertices.Count;
Int32 iCalculations = 0;
VertexDegrees oVertexIDDictionary = new VertexDegrees(iVertices);
graphMetrics = oVertexIDDictionary;
foreach (IVertex oVertex in oVertices)
{
// Check for cancellation and report progress every
// VerticesPerProgressReport calculations.
if (
(iCalculations % VerticesPerProgressReport == 0)
&&
!ReportProgressAndCheckCancellationPending(
iCalculations, iVertices, backgroundWorker)
)
{
return (false);
}
Int32 iInDegree, iOutDegree;
CalculateVertexDegrees(oVertex, out iInDegree, out iOutDegree);
oVertexIDDictionary.Add(oVertex.ID, iInDegree, iOutDegree);
iCalculations++;
}
return (true);
}