Smrf.NodeXL.ExcelTemplate.VertexDegreeCalculator2.FilterGraphMetricColumns C# (CSharp) Method

FilterGraphMetricColumns() protected method

protected FilterGraphMetricColumns ( IGraph oGraph, CalculateGraphMetricsContext oCalculateGraphMetricsContext, List oInDegreeGraphMetricValues, List oOutDegreeGraphMetricValues, List oDegreeGraphMetricValues ) : Smrf.NodeXL.ExcelTemplate.GraphMetricColumn[]
oGraph IGraph
oCalculateGraphMetricsContext CalculateGraphMetricsContext
oInDegreeGraphMetricValues List
oOutDegreeGraphMetricValues List
oDegreeGraphMetricValues List
return Smrf.NodeXL.ExcelTemplate.GraphMetricColumn[]
    FilterGraphMetricColumns
    (
        IGraph oGraph,
        CalculateGraphMetricsContext oCalculateGraphMetricsContext,
        List<GraphMetricValueWithID> oInDegreeGraphMetricValues,
        List<GraphMetricValueWithID> oOutDegreeGraphMetricValues,
        List<GraphMetricValueWithID> oDegreeGraphMetricValues
    )
    {
        AssertValid();

        Debug.Assert(oGraph != null);
        Debug.Assert(oCalculateGraphMetricsContext != null);
        Debug.Assert(oInDegreeGraphMetricValues != null);
        Debug.Assert(oOutDegreeGraphMetricValues != null);
        Debug.Assert(oDegreeGraphMetricValues != null);

        Boolean bGraphIsDirected =
            (oGraph.Directedness == GraphDirectedness.Directed);

        Boolean bCalculateInDegree = bGraphIsDirected &&
            oCalculateGraphMetricsContext.ShouldCalculateGraphMetrics(
                GraphMetrics.InDegree);

        Boolean bCalculateOutDegree = bGraphIsDirected &&
            oCalculateGraphMetricsContext.ShouldCalculateGraphMetrics(
                GraphMetrics.OutDegree);

        Boolean bCalculateDegree = !bGraphIsDirected &&
            oCalculateGraphMetricsContext.ShouldCalculateGraphMetrics(
                GraphMetrics.Degree);

        // Figure out which columns to add.

        List<GraphMetricColumn> oGraphMetricColumns =
            new List<GraphMetricColumn>();

        if (bCalculateInDegree)
        {
            oGraphMetricColumns.Add( new GraphMetricColumnWithID(
                WorksheetNames.Vertices, TableNames.Vertices,
                VertexTableColumnNames.InDegree,
                ExcelTableUtil.AutoColumnWidth, NumericFormat,
                CellStyleNames.GraphMetricGood,
                oInDegreeGraphMetricValues.ToArray() ) );
        }

        if (bCalculateOutDegree)
        {
            oGraphMetricColumns.Add( new GraphMetricColumnWithID(
                WorksheetNames.Vertices, TableNames.Vertices,
                VertexTableColumnNames.OutDegree,
                ExcelTableUtil.AutoColumnWidth, NumericFormat,
                CellStyleNames.GraphMetricGood,
                oOutDegreeGraphMetricValues.ToArray() ) );
        }

        if (bCalculateDegree)
        {
            oGraphMetricColumns.Add( new GraphMetricColumnWithID(
                WorksheetNames.Vertices, TableNames.Vertices,
                VertexTableColumnNames.Degree,
                ExcelTableUtil.AutoColumnWidth, NumericFormat,
                CellStyleNames.GraphMetricGood,
                oDegreeGraphMetricValues.ToArray() ) );
        }

        return ( oGraphMetricColumns.ToArray() );
    }