AddEdgeColorAttributesToDConnectorMotif
    (
        ExcelTemplateGroupInfo oGroup,
        Boolean bEdgeColorColumnAutoFilled,
        AutoFillColorColumnResults oEdgeColorResults,
        ColorColumnAutoFillUserSettings oEdgeColorDetails,
        Dictionary<Int32, Object> oEdgeColorSourceDictionary,
        ReadWorkbookContext oReadWorkbookContext,
        CollapsedGroupAttributes oCollapsedGroupAttributes,
        Int32 iAnchorVertices
    )
    {
        Debug.Assert(oGroup != null);
        Debug.Assert(oEdgeColorResults != null);
        Debug.Assert(oReadWorkbookContext != null);
        Debug.Assert(oCollapsedGroupAttributes != null);
        Debug.Assert(iAnchorVertices >= 0);

        // If the edge color column was autofilled, get the average color for
        // the edges incident to the D-connector motif's first anchor, then its
        // second anchor, and so on.  Otherwise, don't do anything.

        if (!bEdgeColorColumnAutoFilled)
        {
            return;
        }

        for (Int32 iAnchorVertexIndex = 0;
            iAnchorVertexIndex < iAnchorVertices;
            iAnchorVertexIndex++)
        {
            Color oAverageColor;

            if ( TableColumnMapper.TryMapAverageColor(

                    GetRowIDsToAverageForEdges(oGroup,
                        oCollapsedGroupAttributes, iAnchorVertexIndex),

                    oEdgeColorSourceDictionary,
                    oEdgeColorResults.SourceCalculationNumber1,
                    oEdgeColorResults.SourceCalculationNumber2,
                    oEdgeColorResults.DestinationColor1,
                    oEdgeColorResults.DestinationColor2,
                    oEdgeColorDetails.UseLogs,
                    out oAverageColor)
                )
            {
                oCollapsedGroupAttributes.Add(

                    CollapsedGroupAttributeKeys.GetAnchorVertexEdgeColorKey(
                        iAnchorVertexIndex),

                    oReadWorkbookContext.ColorConverter2.GraphToWorkbook(
                        oAverageColor)
                    );
            }
        }
    }
    AddEdgeWidthAttributesToDConnectorMotif
    (
        ExcelTemplateGroupInfo oGroup,
        Boolean bEdgeWidthColumnAutoFilled,
        AutoFillNumericRangeColumnResults oEdgeWidthResults,
        NumericRangeColumnAutoFillUserSettings oEdgeWidthDetails,
        Dictionary<Int32, Object> oEdgeWidthSourceDictionary,
        ReadWorkbookContext oReadWorkbookContext,
        CollapsedGroupAttributes oCollapsedGroupAttributes,
        Int32 iAnchorVertices
    )
    {
        Debug.Assert(oGroup != null);
        Debug.Assert(oEdgeWidthResults != null);
        Debug.Assert(oReadWorkbookContext != null);
        Debug.Assert(oCollapsedGroupAttributes != null);
        Debug.Assert(iAnchorVertices >= 0);

        // If the edge width column was autofilled, get the average width for
        // the edges incident to the two-connector motif's first anchor, then
        // its second anchor.  Otherwise, don't do anything.

        if (!bEdgeWidthColumnAutoFilled)
        {
            return;
        }

        for (Int32 iAnchorVertexIndex = 0;
            iAnchorVertexIndex < iAnchorVertices;
            iAnchorVertexIndex++)
        {
            Double dAverageEdgeWidth;

            if ( TableColumnMapper.TryMapAverageNumber(

                    GetRowIDsToAverageForEdges(oGroup,
                        oCollapsedGroupAttributes, iAnchorVertexIndex),

                    oEdgeWidthSourceDictionary,
                    oEdgeWidthResults.SourceCalculationNumber1,
                    oEdgeWidthResults.SourceCalculationNumber2,
                    oEdgeWidthResults.DestinationNumber1,
                    oEdgeWidthResults.DestinationNumber2,
                    oEdgeWidthDetails.UseLogs,
                    out dAverageEdgeWidth
                    )
                )
            {
                oCollapsedGroupAttributes.Add(

                    CollapsedGroupAttributeKeys.GetAnchorVertexEdgeWidthKey(
                        iAnchorVertexIndex),

                    dAverageEdgeWidth
                    );
            }
        }
    }
    AddVertexColorAttributeToMotif
    (
        ExcelTemplateGroupInfo oGroup,
        String sType,
        Boolean bVertexColorColumnAutoFilled,
        AutoFillColorColumnResults oVertexColorResults,
        ColorColumnAutoFillUserSettings oVertexColorDetails,
        Dictionary<Int32, Object> oVertexColorSourceDictionary,
        ReadWorkbookContext oReadWorkbookContext,
        CollapsedGroupAttributes oCollapsedGroupAttributes
    )
    {
        Debug.Assert(oGroup != null);
        Debug.Assert( !String.IsNullOrEmpty(sType) );
        Debug.Assert(oVertexColorResults != null);
        Debug.Assert(oReadWorkbookContext != null);
        Debug.Assert(oCollapsedGroupAttributes != null);

        Color oColor;

        // If the vertex color column was autofilled, get the average color
        // for the vertices in the motif.

        if (
            !bVertexColorColumnAutoFilled
            ||
            !TableColumnMapper.TryMapAverageColor(

                GetRowIDsToAverageForVertexColor(oGroup,
                    oCollapsedGroupAttributes, sType),

                oVertexColorSourceDictionary,
                oVertexColorResults.SourceCalculationNumber1,
                oVertexColorResults.SourceCalculationNumber2,
                oVertexColorResults.DestinationColor1,
                oVertexColorResults.DestinationColor2,
                oVertexColorDetails.UseLogs,
                out oColor)
            )
        {
            // Default to the color that was assigned to the group.

            oColor = oGroup.VertexColor;
        }

        oCollapsedGroupAttributes.Add(
            CollapsedGroupAttributeKeys.VertexColor,
            oReadWorkbookContext.ColorConverter2.GraphToWorkbook(oColor)
            );
    }