/// <summary>
        /// Gets an edge given an edge id. Throws if no such edge exist.
        /// </summary>
        /// <param name="edgeId">The id of the edge</param>
        /// <returns>The edge with matching id if it exists</returns>
        public Edge GetEdge(EdgeId edgeId)
        {
            if (Unrestricted)
            {
                UnrestrictedEdge headTail;
                if (m_unrestrictedEdges.TryGetValue(edgeId, out headTail))
                {
                    VertexType vt   = headTail.m_headVertexType;
                    Vertex     head = vt.GetVertex(headTail.m_headVertexId);
                    vt = headTail.m_tailVertexType;
                    Vertex tail = vt.GetVertex(headTail.m_tailVertexId);
                    return(new Edge(MyGraph, this, edgeId, head, tail));
                }
            }
            else
            {
                UInt64 vertexVertex;
                if (m_restrictedEdges.TryGetValue(edgeId, out vertexVertex))
                {
                    VertexId headId = (VertexId)(vertexVertex >> 32);
                    Vertex   head   = HeadType.GetVertex(headId);
                    Vertex   tail   = TailType.GetVertex((VertexId)vertexVertex);
                    return(new Edge(MyGraph, this, edgeId, head, tail));
                }
            }

            throw new EdgeDoesNotExistException();
        }
Beispiel #2
0
 /// <summary>
 /// Gets an edge given an edge id. Throws if no such edge exist.
 /// </summary>
 /// <param name="edgeId">The id of the edge</param>
 /// <param name="polymorphic">If true and id isn't found in this EdgeType continue search into sub types</param>
 /// <param name="errorIfNotFound">Indicate what to do if <see cref="Edge"/> does not exist</param>
 /// <returns>The edge with matching id if it exists</returns>
 public Edge GetEdge(EdgeId edgeId, bool polymorphic = false, bool errorIfNotFound = true)
 {
     if (Unrestricted)
     {
         UnrestrictedEdge headTail;
         if (m_unrestrictedEdges.TryGetValue(edgeId, out headTail))
         {
             VertexType vt   = headTail.m_headVertexType;
             Vertex     head = vt.GetVertex(headTail.m_headVertexId);
             vt = headTail.m_tailVertexType;
             Vertex tail = vt.GetVertex(headTail.m_tailVertexId);
             return(new Edge(MyGraph, this, edgeId, head, tail));
         }
     }
     else
     {
         UInt64 vertexVertex;
         if (m_restrictedEdges.TryGetValue(edgeId, out vertexVertex))
         {
             VertexId headId = (VertexId)(vertexVertex >> 32);
             Vertex   head   = HeadType.GetVertex(headId);
             Vertex   tail   = TailType.GetVertex((VertexId)vertexVertex);
             return(new Edge(MyGraph, this, edgeId, head, tail));
         }
     }
     if (polymorphic)
     {
         foreach (var et in m_subTypes)
         {
             var e = et.GetEdge(edgeId, polymorphic, false);
             if (e != null)
             {
                 return(e);
             }
         }
     }
     if (errorIfNotFound)
     {
         throw new EdgeDoesNotExistException();
     }
     return(null);
 }