Finding Vertices

Daniel has posted the set of three queries to find vertices of a given quality.

FIXME They don't seem to work in TP3.


gremlin> g = new TinkerGraph()
==>tinkergraph[vertices:0 edges:0]
gremlin> v1 = g.addVertex(id, 1).next()
gremlin> v2 = g.addVertex(id, 2).next()
gremlin> v3 = g.addVertex(id, 3).next()
gremlin> v4 = g.addVertex(id, 4).next()
gremlin> v5 = g.addVertex(id, 5).next()
gremlin> v7 = g.addVertex(id, 7).next()
gremlin> v1.addEdge("a", v2)
gremlin> v3.addEdge("a", v2)
gremlin> v4.addEdge("a", v5)
gremlin> v7.addEdge("a", v4)

Find vertices with only incoming edges

g.V().filter { !it.outE().hasNext() }

Find vertices with only outgoing edges

g.V().filter { !it.inE().hasNext() }

Find vertices with at most 1 edge on any side

g.V().filter { it.bothE().count() == 1 }

results matching ""

    No results matching ""