TryCalculateGraphMetricsInternal
(
IGraph oGraph,
CalculateGraphMetricsContext oCalculateGraphMetricsContext,
List<GraphMetricColumn> oGraphMetricColumns
)
{
Debug.Assert(oGraph != null);
Debug.Assert(oCalculateGraphMetricsContext != null);
AssertValid();
Int32 iTopNByMetricsIndex = 0;
foreach (TopNByMetricUserSettings oTopNByMetricUserSettings in
oCalculateGraphMetricsContext.GraphMetricUserSettings.
TopNByMetricsToCalculate)
{
if (oCalculateGraphMetricsContext.BackgroundWorker
.CancellationPending)
{
// The user cancelled.
return (false);
}
if (
oTopNByMetricUserSettings.WorksheetName !=
WorksheetNames.Vertices
||
oTopNByMetricUserSettings.TableName != TableNames.Vertices
||
oTopNByMetricUserSettings.ItemNameColumnName !=
VertexTableColumnNames.VertexName
)
{
// This currently works only for the vertex worksheet.
// GraphMetricCalculationManager.ReadWorkbook() will have to be
// modified to read the cell values in other worksheets when
// top-N-by metrics are extended to support other worksheets.
throw new NotSupportedException();
}
AddColumnsForRankedVertices(oGraph.Vertices,
oTopNByMetricUserSettings.RankedColumnName,
oTopNByMetricUserSettings.N,
WorksheetNames.TopNByMetrics,
TableNames.TopNByMetricsRoot + (iTopNByMetricsIndex + 1),
oTopNByMetricUserSettings.ToString(),
oTopNByMetricUserSettings.RankedColumnName,
oGraphMetricColumns);
iTopNByMetricsIndex++;
}
return (true);
}