AddToRowIDDictionary() public method

public AddToRowIDDictionary ( ExcelTableReader row, IIdentityProvider edgeOrVertex, System.Boolean isEdge ) : void
row Smrf.AppLib.ExcelTableReader
edgeOrVertex IIdentityProvider
isEdge System.Boolean
return void
        ReadVertexTable
        (
            ListObject oVertexTable,
            ReadWorkbookContext oReadWorkbookContext,
            IGraph oGraph,
            out Boolean bLayoutAndZOrderSet
        )
        {
            Debug.Assert(oVertexTable != null);
            Debug.Assert(oReadWorkbookContext != null);
            Debug.Assert(oGraph != null);
            AssertValid();

            bLayoutAndZOrderSet = false;

            if (GetTableColumnIndex(oVertexTable,
                                    VertexTableColumnNames.VertexName, false) == NoSuchColumn)
            {
                // Nothing can be done without vertex names.

                return;
            }

            Boolean bReadAllEdgeAndVertexColumns =
                oReadWorkbookContext.ReadAllEdgeAndVertexColumns;

            if (oReadWorkbookContext.FillIDColumns)
            {
                FillIDColumn(oVertexTable);
            }

            // Get the names of all the column pairs that are used to add custom
            // menu items to the vertex context menu in the graph.

            TableColumnAdder oTableColumnAdder = new TableColumnAdder();

            ICollection <KeyValuePair <String, String> > aoCustomMenuItemPairNames =
                oTableColumnAdder.GetColumnPairNames(oVertexTable,
                                                     VertexTableColumnNames.CustomMenuItemTextBase,
                                                     VertexTableColumnNames.CustomMenuItemActionBase);

            IVertexCollection oVertices = oGraph.Vertices;

            Dictionary <String, IVertex> oVertexNameDictionary =
                oReadWorkbookContext.VertexNameDictionary;

            Dictionary <Int32, IIdentityProvider> oEdgeRowIDDictionary =
                oReadWorkbookContext.EdgeRowIDDictionary;

            BooleanConverter oBooleanConverter =
                oReadWorkbookContext.BooleanConverter;

            VertexVisibilityConverter oVertexVisibilityConverter =
                new VertexVisibilityConverter();

            VertexLabelPositionConverter oVertexLabelPositionConverter =
                new VertexLabelPositionConverter();

            ExcelTableReader oExcelTableReader =
                new ExcelTableReader(oVertexTable);

            HashSet <String> oColumnNamesToExclude = new HashSet <String>(
                new String[] {
                VertexTableColumnNames.VertexName
            });

            foreach (ExcelTableReader.ExcelTableRow oRow in
                     oExcelTableReader.GetRows())
            {
                // Get the name of the vertex.

                String sVertexName;

                if (!oRow.TryGetNonEmptyStringFromCell(
                        VertexTableColumnNames.VertexName, out sVertexName))
                {
                    continue;
                }

                // If the vertex was added to the graph as part of an edge,
                // retrieve the vertex.

                IVertex oVertex;

                if (!oVertexNameDictionary.TryGetValue(sVertexName, out oVertex))
                {
                    oVertex = null;
                }

                // Assume a default visibility.

                Visibility eVisibility = Visibility.ShowIfInAnEdge;
                String     sVisibility;

                if (oRow.TryGetNonEmptyStringFromCell(
                        CommonTableColumnNames.Visibility, out sVisibility))
                {
                    if (!oVertexVisibilityConverter.TryWorkbookToGraph(
                            sVisibility, out eVisibility))
                    {
                        OnInvalidVisibility(oRow);
                    }
                }

                switch (eVisibility)
                {
                case Visibility.ShowIfInAnEdge:

                    // If the vertex is part of an edge, show it using the
                    // specified vertex attributes.  Otherwise, skip the vertex
                    // row.

                    if (oVertex == null)
                    {
                        continue;
                    }

                    break;

                case Visibility.Skip:

                    // Skip the vertex row and any edge rows that include the
                    // vertex.  Do not read them into the graph.

                    if (oVertex != null)
                    {
                        // Remove the vertex and its incident edges from the
                        // graph and dictionaries.

                        RemoveVertex(oVertex, oReadWorkbookContext, oGraph);
                    }

                    continue;

                case Visibility.Hide:

                    // If the vertex is part of an edge, hide it and its
                    // incident edges.  Otherwise, skip the vertex row.

                    if (oVertex == null)
                    {
                        continue;
                    }

                    HideVertex(oVertex);

                    break;

                case Visibility.Show:

                    // Show the vertex using the specified attributes
                    // regardless of whether it is part of an edge.

                    if (oVertex == null)
                    {
                        oVertex = CreateVertex(sVertexName, oVertices,
                                               oVertexNameDictionary);
                    }

                    oVertex.SetValue(
                        ReservedMetadataKeys.VertexHasVisibilityOfShow, null);

                    break;

                default:

                    Debug.Assert(false);
                    break;
                }

                Debug.Assert(oVertex != null);

                // If ReadWorkbookContext.FillIDColumns is true, add the vertex to
                // the vertex row ID dictionary and set the vertex's Tag to the row
                // ID.

                oReadWorkbookContext.AddToRowIDDictionary(oRow, oVertex, false);

                if (bReadAllEdgeAndVertexColumns)
                {
                    // All columns except the vertex name should be read and stored
                    // as metadata on the vertex.

                    ReadAllColumns(oExcelTableReader, oRow, oVertex,
                                   oColumnNamesToExclude);

                    continue;
                }

                // Layout and z-order.

                if (ReadLayoutAndZOrder(oRow, oVertex))
                {
                    bLayoutAndZOrderSet = true;
                }

                // Location and Locked.

                if (!oReadWorkbookContext.IgnoreVertexLocations)
                {
                    System.Drawing.PointF oLocation;

                    Boolean bLocationSpecified = TryGetLocation(oRow,
                                                                VertexTableColumnNames.X, VertexTableColumnNames.Y,
                                                                oReadWorkbookContext.VertexLocationConverter,
                                                                out oLocation);

                    if (bLocationSpecified)
                    {
                        oVertex.Location = oLocation;
                    }

                    ReadLocked(oRow, oBooleanConverter, bLocationSpecified,
                               oVertex);
                }

                // Polar coordinates.

                ReadPolarCoordinates(oRow, oVertex);

                // Marked.

                ReadMarked(oRow, oBooleanConverter, oVertex);

                // Custom menu items.

                if (aoCustomMenuItemPairNames.Count > 0)
                {
                    ReadCustomMenuItems(oRow, aoCustomMenuItemPairNames, oVertex);
                }

                // Alpha.

                ReadAlpha(oRow, oVertex);

                // Tooltip.

                ReadCellAndSetMetadata(oRow, VertexTableColumnNames.ToolTip,
                                       oVertex, ReservedMetadataKeys.PerVertexToolTip);

                // Label.

                if (oReadWorkbookContext.ReadVertexLabels)
                {
                    ReadCellAndSetMetadata(oRow, VertexTableColumnNames.Label,
                                           oVertex, ReservedMetadataKeys.PerVertexLabel);
                }

                // Label fill color.

                ReadColor(oRow, VertexTableColumnNames.LabelFillColor, oVertex,
                          ReservedMetadataKeys.PerVertexLabelFillColor,
                          oReadWorkbookContext.ColorConverter2);

                // Label position.

                ReadLabelPosition(oRow, oVertexLabelPositionConverter, oVertex);

                // Radius.

                Nullable <Single> oRadiusWorkbook = new Nullable <Single>();

                oRadiusWorkbook = ReadRadius(oRow,
                                             oReadWorkbookContext.VertexRadiusConverter, oVertex);

                // Shape.

                VertexShape eVertexShape;

                if (!ReadShape(oRow, oVertex, out eVertexShape))
                {
                    eVertexShape = oReadWorkbookContext.DefaultVertexShape;
                }

                // Label font size.

                if (eVertexShape == VertexShape.Label && oRadiusWorkbook.HasValue)
                {
                    // The vertex radius is used to specify font size when the
                    // shape is Label.

                    oVertex.SetValue(ReservedMetadataKeys.PerVertexLabelFontSize,
                                     oReadWorkbookContext.VertexRadiusConverter.
                                     WorkbookToLabelFontSize(oRadiusWorkbook.Value));
                }

                // Image URI.

                if (eVertexShape == VertexShape.Image &&
                    oReadWorkbookContext.ReadVertexImages)
                {
                    ReadImageUri(oRow, oVertex,
                                 oReadWorkbookContext.VertexRadiusConverter,

                                 oRadiusWorkbook.HasValue ? oRadiusWorkbook :
                                 oReadWorkbookContext.DefaultVertexImageSize
                                 );
                }

                // Color

                ReadColor(oRow, VertexTableColumnNames.Color, oVertex,
                          ReservedMetadataKeys.PerColor,
                          oReadWorkbookContext.ColorConverter2);
            }

            if (bReadAllEdgeAndVertexColumns)
            {
                // Store the vertex column names on the graph.

                oGraph.SetValue(ReservedMetadataKeys.AllVertexMetadataKeys,
                                FilterColumnNames(oExcelTableReader, oColumnNamesToExclude));
            }
        }
Esempio n. 2
0
        ReadEdgeTable
        (
            ListObject oEdgeTable,
            ReadWorkbookContext oReadWorkbookContext,
            IGraph oGraph
        )
        {
            Debug.Assert(oEdgeTable != null);
            Debug.Assert(oReadWorkbookContext != null);
            Debug.Assert(oGraph != null);
            AssertValid();

            Boolean bReadAllEdgeAndVertexColumns =
                oReadWorkbookContext.ReadAllEdgeAndVertexColumns;

            if (oReadWorkbookContext.FillIDColumns)
            {
                FillIDColumn(oEdgeTable);
            }

            Dictionary <String, IVertex> oVertexNameDictionary =
                oReadWorkbookContext.VertexNameDictionary;

            EdgeVisibilityConverter oEdgeVisibilityConverter =
                new EdgeVisibilityConverter();

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

            ExcelTableReader  oExcelTableReader = new ExcelTableReader(oEdgeTable);
            IVertexCollection oVertices         = oGraph.Vertices;
            IEdgeCollection   oEdges            = oGraph.Edges;

            HashSet <String> oColumnNamesToExclude = new HashSet <String>(
                new String[] {
                EdgeTableColumnNames.Vertex1Name,
                EdgeTableColumnNames.Vertex2Name
            });

            foreach (ExcelTableReader.ExcelTableRow oRow in
                     oExcelTableReader.GetRows())
            {
                // Get the names of the edge's vertices.

                String sVertex1Name, sVertex2Name;

                Boolean bVertex1IsEmpty = !oRow.TryGetNonEmptyStringFromCell(
                    EdgeTableColumnNames.Vertex1Name, out sVertex1Name);

                Boolean bVertex2IsEmpty = !oRow.TryGetNonEmptyStringFromCell(
                    EdgeTableColumnNames.Vertex2Name, out sVertex2Name);

                if (bVertex1IsEmpty && bVertex2IsEmpty)
                {
                    // Skip empty rows.

                    continue;
                }

                if (bVertex1IsEmpty || bVertex2IsEmpty)
                {
                    // A half-empty row is an error.

                    OnHalfEmptyEdgeRow(oRow, bVertex1IsEmpty);
                }

                // Assume a default visibility.

                Visibility eVisibility = Visibility.Show;

                String sVisibility;

                if (
                    oRow.TryGetNonEmptyStringFromCell(
                        CommonTableColumnNames.Visibility, out sVisibility)
                    &&
                    !oEdgeVisibilityConverter.TryWorkbookToGraph(
                        sVisibility, out eVisibility)
                    )
                {
                    OnInvalidVisibility(oRow);
                }

                if (eVisibility == Visibility.Skip)
                {
                    // Skip the edge an continue to the next edge.

                    continue;
                }

                // Create the specified vertices or retrieve them from the
                // dictionary.

                IVertex oVertex1 = VertexNameToVertex(
                    sVertex1Name, oVertices, oVertexNameDictionary);

                IVertex oVertex2 = VertexNameToVertex(
                    sVertex2Name, oVertices, oVertexNameDictionary);

                // Add an edge connecting the vertices.

                IEdge oEdge = oEdges.Add(oVertex1, oVertex2, bGraphIsDirected);

                // If ReadWorkbookContext.FillIDColumns is true, add the edge to
                // the edge row ID dictionary and set the edge's Tag to the row ID.

                oReadWorkbookContext.AddToRowIDDictionary(oRow, oEdge, true);

                if (bReadAllEdgeAndVertexColumns)
                {
                    // All columns except the vertex names should be read and
                    // stored as metadata on the edge.

                    ReadAllColumns(oExcelTableReader, oRow, oEdge,
                                   oColumnNamesToExclude);

                    continue;
                }

                if (eVisibility == Visibility.Hide)
                {
                    // Hide the edge and continue to the next edge.

                    oEdge.SetValue(ReservedMetadataKeys.Visibility,
                                   VisibilityKeyValue.Hidden);

                    continue;
                }

                // Alpha.

                Boolean bAlphaIsZero = ReadAlpha(oRow, oEdge);

                if (bAlphaIsZero)
                {
                    continue;
                }

                // Color.

                ReadColor(oRow, EdgeTableColumnNames.Color, oEdge,
                          ReservedMetadataKeys.PerColor,
                          oReadWorkbookContext.ColorConverter2);

                // Width.

                ReadWidth(oRow, oReadWorkbookContext.EdgeWidthConverter, oEdge);

                // Style.

                ReadStyle(oRow, oReadWorkbookContext.EdgeStyleConverter, oEdge);

                // Label.

                if (oReadWorkbookContext.ReadEdgeLabels)
                {
                    ReadCellAndSetMetadata(oRow, EdgeTableColumnNames.Label, oEdge,
                                           ReservedMetadataKeys.PerEdgeLabel);

                    ReadColor(oRow, EdgeTableColumnNames.LabelTextColor, oEdge,
                              ReservedMetadataKeys.PerEdgeLabelTextColor,
                              oReadWorkbookContext.ColorConverter2);

                    ReadLabelFontSize(oRow, oReadWorkbookContext.FontSizeConverter,
                                      oEdge);
                }

                // Weight.

                if (oReadWorkbookContext.ReadEdgeWeights)
                {
                    ReadEdgeWeight(oRow, oEdge);
                }
            }

            if (bReadAllEdgeAndVertexColumns)
            {
                // Store the edge column names on the graph.

                oGraph.SetValue(ReservedMetadataKeys.AllEdgeMetadataKeys,
                                FilterColumnNames(oExcelTableReader, oColumnNamesToExclude));
            }
        }
    ReadVertexTable
    (
        ListObject oVertexTable,
        ReadWorkbookContext oReadWorkbookContext,
        IGraph oGraph,
        out Boolean bLayoutAndZOrderSet
    )
    {
        Debug.Assert(oVertexTable != null);
        Debug.Assert(oReadWorkbookContext != null);
        Debug.Assert(oGraph != null);
        AssertValid();

        bLayoutAndZOrderSet = false;

        if (GetTableColumnIndex(oVertexTable,
            VertexTableColumnNames.VertexName, false) == NoSuchColumn)
        {
            // Nothing can be done without vertex names.

            return;
        }

        Boolean bReadAllEdgeAndVertexColumns =
            oReadWorkbookContext.ReadAllEdgeAndVertexColumns;

        if (oReadWorkbookContext.FillIDColumns)
        {
            FillIDColumn(oVertexTable);
        }

        // Get the names of all the column pairs that are used to add custom
        // menu items to the vertex context menu in the graph.

        TableColumnAdder oTableColumnAdder = new TableColumnAdder();

        ICollection< KeyValuePair<String, String> > aoCustomMenuItemPairNames =
            oTableColumnAdder.GetColumnPairNames(oVertexTable,
                VertexTableColumnNames.CustomMenuItemTextBase,
                VertexTableColumnNames.CustomMenuItemActionBase);

        IVertexCollection oVertices = oGraph.Vertices;

        Dictionary<String, IVertex> oVertexNameDictionary =
            oReadWorkbookContext.VertexNameDictionary;

        Dictionary<Int32, IIdentityProvider> oEdgeRowIDDictionary =
            oReadWorkbookContext.EdgeRowIDDictionary;

        BooleanConverter oBooleanConverter =
            oReadWorkbookContext.BooleanConverter;

        VertexVisibilityConverter oVertexVisibilityConverter =
            new VertexVisibilityConverter();

        VertexLabelPositionConverter oVertexLabelPositionConverter =
            new VertexLabelPositionConverter();

        ExcelTableReader oExcelTableReader =
            new ExcelTableReader(oVertexTable);

        HashSet<String> oColumnNamesToExclude = new HashSet<String>(
            new String[] {
                VertexTableColumnNames.VertexName
                } );

        foreach ( ExcelTableReader.ExcelTableRow oRow in
            oExcelTableReader.GetRows() )
        {
            // Get the name of the vertex.

            String sVertexName;

            if ( !oRow.TryGetNonEmptyStringFromCell(
                VertexTableColumnNames.VertexName, out sVertexName) )
            {
                continue;
            }

            // If the vertex was added to the graph as part of an edge,
            // retrieve the vertex.

            IVertex oVertex;

            if ( !oVertexNameDictionary.TryGetValue(sVertexName, out oVertex) )
            {
                oVertex = null;
            }

            // Assume a default visibility.

            Visibility eVisibility = Visibility.ShowIfInAnEdge;
            String sVisibility;

            if ( oRow.TryGetNonEmptyStringFromCell(
                    CommonTableColumnNames.Visibility, out sVisibility) )
            {
                if ( !oVertexVisibilityConverter.TryWorkbookToGraph(
                    sVisibility, out eVisibility) )
                {
                    OnInvalidVisibility(oRow);
                }
            }

            switch (eVisibility)
            {
                case Visibility.ShowIfInAnEdge:

                    // If the vertex is part of an edge, show it using the
                    // specified vertex attributes.  Otherwise, skip the vertex
                    // row.

                    if (oVertex == null)
                    {
                        continue;
                    }

                    break;

                case Visibility.Skip:

                    // Skip the vertex row and any edge rows that include the
                    // vertex.  Do not read them into the graph.

                    if (oVertex != null)
                    {
                        // Remove the vertex and its incident edges from the
                        // graph and dictionaries.

                        RemoveVertex(oVertex, oReadWorkbookContext, oGraph);
                    }

                    continue;

                case Visibility.Hide:

                    // If the vertex is part of an edge, hide it and its
                    // incident edges.  Otherwise, skip the vertex row.

                    if (oVertex == null)
                    {
                        continue;
                    }

                    HideVertex(oVertex);

                    break;

                case Visibility.Show:

                    // Show the vertex using the specified attributes
                    // regardless of whether it is part of an edge.

                    if (oVertex == null)
                    {
                        oVertex = CreateVertex(sVertexName, oVertices,
                            oVertexNameDictionary);
                    }

                    oVertex.SetValue(
                        ReservedMetadataKeys.VertexHasVisibilityOfShow, null);

                    break;

                default:

                    Debug.Assert(false);
                    break;
            }

            Debug.Assert(oVertex != null);

            // If ReadWorkbookContext.FillIDColumns is true, add the vertex to
            // the vertex row ID dictionary and set the vertex's Tag to the row
            // ID.

            oReadWorkbookContext.AddToRowIDDictionary(oRow, oVertex, false);

            if (bReadAllEdgeAndVertexColumns)
            {
                // All columns except the vertex name should be read and stored
                // as metadata on the vertex.

                ReadAllColumns( oExcelTableReader, oRow, oVertex,
                    oColumnNamesToExclude);

                continue;
            }

            // Layout and z-order.

            if ( ReadLayoutAndZOrder(oRow, oVertex) )
            {
                bLayoutAndZOrderSet = true;
            }

            // Location and Locked.

            if (!oReadWorkbookContext.IgnoreVertexLocations)
            {
                System.Drawing.PointF oLocation;

                Boolean bLocationSpecified = TryGetLocation(oRow,
                    VertexTableColumnNames.X, VertexTableColumnNames.Y,
                    oReadWorkbookContext.VertexLocationConverter,
                    out oLocation);

                if (bLocationSpecified)
                {
                    oVertex.Location = oLocation;
                }

                ReadLocked(oRow, oBooleanConverter, bLocationSpecified,
                    oVertex);
            }

            // Polar coordinates.

            ReadPolarCoordinates(oRow, oVertex);

            // Marked.

            ReadMarked(oRow, oBooleanConverter, oVertex);

            // Custom menu items.

            if (aoCustomMenuItemPairNames.Count > 0)
            {
                ReadCustomMenuItems(oRow, aoCustomMenuItemPairNames, oVertex);
            }

            // Alpha.

            ReadAlpha(oRow, oVertex);

            // Tooltip.

            ReadCellAndSetMetadata(oRow, VertexTableColumnNames.ToolTip,
                oVertex, ReservedMetadataKeys.PerVertexToolTip);

            // Label.

            if (oReadWorkbookContext.ReadVertexLabels)
            {
                ReadCellAndSetMetadata(oRow, VertexTableColumnNames.Label,
                    oVertex, ReservedMetadataKeys.PerVertexLabel);
            }

            // Label fill color.

            ReadColor(oRow, VertexTableColumnNames.LabelFillColor, oVertex,
                ReservedMetadataKeys.PerVertexLabelFillColor,
                oReadWorkbookContext.ColorConverter2);

            // Label position.

            ReadLabelPosition(oRow, oVertexLabelPositionConverter, oVertex);

            // Radius.

            Nullable<Single> oRadiusWorkbook = new Nullable<Single>();

            oRadiusWorkbook = ReadRadius(oRow,
                oReadWorkbookContext.VertexRadiusConverter, oVertex);

            // Shape.

            VertexShape eVertexShape;

            if ( !ReadShape(oRow, oVertex, out eVertexShape) )
            {
                eVertexShape = oReadWorkbookContext.DefaultVertexShape;
            }

            // Label font size.

            if (eVertexShape == VertexShape.Label && oRadiusWorkbook.HasValue)
            {
                // The vertex radius is used to specify font size when the
                // shape is Label.

                oVertex.SetValue( ReservedMetadataKeys.PerVertexLabelFontSize,
                    oReadWorkbookContext.VertexRadiusConverter.
                        WorkbookToLabelFontSize(oRadiusWorkbook.Value) );
            }

            // Image URI.

            if (eVertexShape == VertexShape.Image &&
                oReadWorkbookContext.ReadVertexImages)
            {
                ReadImageUri(oRow, oVertex,
                    oReadWorkbookContext.VertexRadiusConverter,

                    oRadiusWorkbook.HasValue ? oRadiusWorkbook :
                        oReadWorkbookContext.DefaultVertexImageSize
                    );
            }

            // Color

            ReadColor(oRow, VertexTableColumnNames.Color, oVertex,
                ReservedMetadataKeys.PerColor,
                oReadWorkbookContext.ColorConverter2);
        }

        if (bReadAllEdgeAndVertexColumns)
        {
            // Store the vertex column names on the graph.

            oGraph.SetValue( ReservedMetadataKeys.AllVertexMetadataKeys,
                FilterColumnNames(oExcelTableReader, oColumnNamesToExclude) );
        }
    }
    ReadEdgeTable
    (
        ListObject oEdgeTable,
        ReadWorkbookContext oReadWorkbookContext,
        IGraph oGraph
    )
    {
        Debug.Assert(oEdgeTable != null);
        Debug.Assert(oReadWorkbookContext != null);
        Debug.Assert(oGraph != null);
        AssertValid();

        Boolean bReadAllEdgeAndVertexColumns =
            oReadWorkbookContext.ReadAllEdgeAndVertexColumns;

        if (oReadWorkbookContext.FillIDColumns)
        {
            FillIDColumn(oEdgeTable);
        }

        Dictionary<String, IVertex> oVertexNameDictionary =
            oReadWorkbookContext.VertexNameDictionary;

        EdgeVisibilityConverter oEdgeVisibilityConverter =
            new EdgeVisibilityConverter();

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

        ExcelTableReader oExcelTableReader = new ExcelTableReader(oEdgeTable);
        IVertexCollection oVertices = oGraph.Vertices;
        IEdgeCollection oEdges = oGraph.Edges;

        HashSet<String> oColumnNamesToExclude = new HashSet<String>(
            new String[] {
                EdgeTableColumnNames.Vertex1Name,
                EdgeTableColumnNames.Vertex2Name
                } );

        foreach ( ExcelTableReader.ExcelTableRow oRow in
            oExcelTableReader.GetRows() )
        {
            // Get the names of the edge's vertices.

            String sVertex1Name, sVertex2Name;

            Boolean bVertex1IsEmpty = !oRow.TryGetNonEmptyStringFromCell(
                EdgeTableColumnNames.Vertex1Name, out sVertex1Name);

            Boolean bVertex2IsEmpty = !oRow.TryGetNonEmptyStringFromCell(
                EdgeTableColumnNames.Vertex2Name, out sVertex2Name);

            if (bVertex1IsEmpty && bVertex2IsEmpty)
            {
                // Skip empty rows.

                continue;
            }

            if (bVertex1IsEmpty || bVertex2IsEmpty)
            {
                // A half-empty row is an error.

                OnHalfEmptyEdgeRow(oRow, bVertex1IsEmpty);
            }

            // Assume a default visibility.

            Visibility eVisibility = Visibility.Show;

            String sVisibility;

            if (
                oRow.TryGetNonEmptyStringFromCell(
                    CommonTableColumnNames.Visibility, out sVisibility)
                &&
                !oEdgeVisibilityConverter.TryWorkbookToGraph(
                    sVisibility, out eVisibility)
                )
            {
                OnInvalidVisibility(oRow);
            }

            if (eVisibility == Visibility.Skip)
            {
                // Skip the edge an continue to the next edge.

                continue;
            }

            // Create the specified vertices or retrieve them from the
            // dictionary.

            IVertex oVertex1 = VertexNameToVertex(
                sVertex1Name, oVertices, oVertexNameDictionary);

            IVertex oVertex2 = VertexNameToVertex(
                sVertex2Name, oVertices, oVertexNameDictionary);

            // Add an edge connecting the vertices.

            IEdge oEdge = oEdges.Add(oVertex1, oVertex2, bGraphIsDirected);

            // If ReadWorkbookContext.FillIDColumns is true, add the edge to
            // the edge row ID dictionary and set the edge's Tag to the row ID.

            oReadWorkbookContext.AddToRowIDDictionary(oRow, oEdge, true);

            if (bReadAllEdgeAndVertexColumns)
            {
                // All columns except the vertex names should be read and
                // stored as metadata on the edge.

                ReadAllColumns(oExcelTableReader, oRow, oEdge,
                    oColumnNamesToExclude);

                continue;
            }

            if (eVisibility == Visibility.Hide)
            {
                // Hide the edge and continue to the next edge.

                oEdge.SetValue(ReservedMetadataKeys.Visibility,
                    VisibilityKeyValue.Hidden);

                continue;
            }

            // Alpha.

            Boolean bAlphaIsZero = ReadAlpha(oRow, oEdge);

            if (bAlphaIsZero)
            {
                continue;
            }

            // Color.

            ReadColor(oRow, EdgeTableColumnNames.Color, oEdge,
                ReservedMetadataKeys.PerColor,
                oReadWorkbookContext.ColorConverter2);

            // Width.

            ReadWidth(oRow, oReadWorkbookContext.EdgeWidthConverter, oEdge);

            // Style.

            ReadStyle(oRow, oReadWorkbookContext.EdgeStyleConverter, oEdge);

            // Label.

            if (oReadWorkbookContext.ReadEdgeLabels)
            {
                ReadCellAndSetMetadata(oRow, EdgeTableColumnNames.Label, oEdge,
                    ReservedMetadataKeys.PerEdgeLabel);

                ReadColor(oRow, EdgeTableColumnNames.LabelTextColor, oEdge,
                    ReservedMetadataKeys.PerEdgeLabelTextColor,
                    oReadWorkbookContext.ColorConverter2);

                ReadLabelFontSize(oRow, oReadWorkbookContext.FontSizeConverter,
                    oEdge);
            }

            // Weight.

            if (oReadWorkbookContext.ReadEdgeWeights)
            {
                ReadEdgeWeight(oRow, oEdge);
            }
        }

        if (bReadAllEdgeAndVertexColumns)
        {
            // Store the edge column names on the graph.

            oGraph.SetValue( ReservedMetadataKeys.AllEdgeMetadataKeys,
                FilterColumnNames(oExcelTableReader, oColumnNamesToExclude) );
        }
    }