예제 #1
0
파일: Vertex.cs 프로젝트: slamj1/VelocityDB
 /// <summary>
 /// Return the vertices adjacent to the vertex according to the provided direction and edge labels.
 /// This method does not remove duplicate vertices (i.e. those vertices that are connected by more than one edge).
 /// </summary>
 /// <param name="direction">the direction of the edges of the adjacent vertices</param>
 /// <param name="labels">the labels of the edges of the adjacent vertices</param>
 /// <returns>an IEnumerable of adjacent vertices</returns>
 public IEnumerable <IVertex> GetVertices(Direction direction, params string[] labels)
 {
     if (labels.Length == 0)
     {
         HashSet <EdgeType> edgeTypes = new HashSet <EdgeType>();
         foreach (Edge edge in GetEdges(direction, labels))
         {
             edgeTypes.Add(edge.EdgeType);
         }
         foreach (EdgeType edgeType in edgeTypes)
         {
             foreach (IVertex vertex in m_vertexType.GetVertices(edgeType, this, direction))
             {
                 yield return(vertex);
             }
         }
     }
     else
     {
         foreach (string label in labels)
         {
             EdgeType edgeType = Graph.FindEdgeType(label);
             foreach (IVertex vertex in m_vertexType.GetVertices(edgeType, this, direction))
             {
                 yield return(vertex);
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Add an edge from this Vertex to inVertex of edge type looked up from label, if edge type does not yet exist it is created.
        /// </summary>
        /// <param name="label">The type of edge to create</param>
        /// <param name="inVertex">The head of the new edge</param>
        /// <returns>the new edge</returns>
        public IEdge AddEdge(string label, IVertex inVertex)
        {
            EdgeType edgeType = Graph.FindEdgeType(label);

            if (edgeType == null)
            {
                edgeType = Graph.NewEdgeType(label, true);
            }
            return(Graph.NewEdge(edgeType, this, inVertex as Vertex));
        }
예제 #3
0
파일: Vertex.cs 프로젝트: slamj1/VelocityDB
        /// <summary>
        /// Add an edge from this Vertex to inVertex of edge type looked up from label, if edge type does not yet exist it is created.
        /// </summary>
        /// <param name="edgeId">If not null, this must be a UInt32 to be used as edge id - NOTE: not yet implemented usage</param>
        /// <param name="label">The type of edge to create</param>
        /// <param name="inVertex">The head of the new edge</param>
        /// <returns>the new edge</returns>
        public IEdge AddEdge(object edgeId, string label, IVertex inVertex)
        { // TODO, use edgeId
            if (edgeId != null)
            {
                throw new NotImplementedException("Custom edge id is not implemented");
            }
            EdgeType edgeType = Graph.FindEdgeType(label);

            if (edgeType == null)
            {
                edgeType = Graph.NewEdgeType(label, true);
            }
            return(edgeType.NewEdge(this, inVertex as Vertex));
        }
예제 #4
0
파일: Vertex.cs 프로젝트: slamj1/VelocityDB
 /// <summary>
 /// Enumerates all outgoing edges of selected edge types
 /// </summary>
 /// <param name="labels">Array of edge type names to find edges for or if empty, get all outgoing edges from this vertex type.</param>
 /// <returns>Enumeration of edges</returns>
 IEnumerable <IEdge> GetOutEdges(params string[] labels)
 {
     if (labels.Length == 0)
     {
         foreach (IEdge edge in m_vertexType.GetEdges(this, Direction.Out))
         {
             yield return(edge);
         }
     }
     else
     {
         foreach (string label in labels)
         {
             EdgeType edgeType = Graph.FindEdgeType(label);
             foreach (IEdge edge in m_vertexType.GetEdges(edgeType, this, Direction.Out))
             {
                 yield return(edge);
             }
         }
     }
 }
예제 #5
0
 IEnumerable <IEdge> GetInEdges(params string[] labels)
 {
     if (labels.Length == 0)
     {
         foreach (IEdge edge in vertexType.GetEdges(Graph, this, Direction.In))
         {
             yield return(edge);
         }
     }
     else
     {
         foreach (string label in labels)
         {
             EdgeType edgeType = Graph.FindEdgeType(label);
             if (edgeType != null)
             {
                 foreach (IEdge edge in vertexType.GetEdges(edgeType, this, Direction.In))
                 {
                     yield return(edge);
                 }
             }
         }
     }
 }