public void DeleteLocationVertices() { using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true)) { session.BeginUpdate(); Graph g = Graph.Open(session); // it takes a while to open graph fresh from databases if (g != null) { VertexType userType = g.FindVertexType("User"); VertexType locationType = g.FindVertexType("Location"); EdgeType friendEdgeType = g.FindEdgeType("Friend"); EdgeType userLocationEdgeType = g.FindEdgeType("UserLocation"); for (int i = 1; i < numberOfLocationVertices; i++) { locationType.RemoveVertex(new Vertex(g, locationType, i)); } Assert.IsTrue(userLocationEdgeType.CountEdges() == 0); Assert.IsTrue(userType.GetEdges(userLocationEdgeType, Direction.Out).Count() == 0); session.Commit(); Validate(); } } }
/// <summary> /// Selects all edges from or to this vertex and for the given edge type. /// </summary> /// <param name="edgeType">the id of an EdgeType</param> /// <param name="dir">direction, one of: Out, In, Both</param> /// <returns>a set of Edge</returns> public IEnumerable <IEdge> GetEdges(EdgeType edgeType, Direction dir) { return(m_vertexType.GetEdges(edgeType, this, dir)); }
/// <summary> /// Enumerates all the edges of the given type between two given nodes (tail and head). /// </summary> /// <param name="etype">Type of Edge</param> /// <param name="tail">Outgoing Vertex</param> /// <param name="head">Incoming Vertex</param> /// <returns>Enumeration of Edge</returns> public IEnumerable <IEdge> Edges(EdgeType etype, Vertex tail, Vertex head) { VertexType vertexType = tail.VertexType; return(vertexType.GetEdges(etype, tail, Direction.Out, head)); }