0
votes

I want to start from a vertex, follow outward edges, till I reach a "leaf" vertex, having no more out edges.

I tried

g.V(2).repeat(out().not(hasLabel('region', 'business')).simplePath()).until(outE().count() == 0 )

I couldn't figure out what to pass in until, all examples i found were passing "has" or similar testing a property on the vertex.

I am trying in the Gremlin Console, but will also need it to work from a java application.

Sample Graph :

graph = TinkerGraph.open()
g = graph.traversal()


a1 = g.addV("acc").property(id, 1).next()
a2 = g.addV("acc").property(id, 2).next()
a3 = g.addV("acc").property(id, 3).next()
a4 = g.addV("acc").property(id, 4).next()
a5 = g.addV("acc").property(id, 5).next()

sfid_a = g.addV("sfid").property(id, "a").next()
sfid_b = g.addV("sfid").property(id, "b").next()

cust_x = g.addV("cust").property(id, "x").next()
cust_y = g.addV("cust").property(id, "y").next()

ind = g.addV("region").property(id, "in").next()
usa = g.addV("region").property(id, "us").next()

aws = g.addV("business").property(id, "aws").next()

g.addE('has_payer').from(a2).to(a4)

g.addE('has_sfid').from(a5).to(sfid_b)
g.addE('has_sfid').from(a3).to(sfid_a)
g.addE('has_sfid').from(a4).to(sfid_a)


g.addE('has_cust').from(sfid_b).to(cust_x)
g.addE('has_cust').from(sfid_a).to(cust_x)
g.addE('has_cust').from(cust_x).to(cust_y)
g.addE('has_cust').from(a1).to(cust_y)


g.addE('has_business').from(a1).to(aws)
g.addE('has_business').from(a2).to(aws)
g.addE('has_business').from(a3).to(aws)
g.addE('has_business').from(a4).to(aws)
g.addE('has_business').from(a5).to(aws)


g.addE('has_region').from(a1).to(ind)
g.addE('has_region').from(a1).to(usa)
g.addE('has_region').from(a2).to(ind)
g.addE('has_region').from(a2).to(usa)
g.addE('has_region').from(a3).to(ind)
g.addE('has_region').from(a4).to(usa)
g.addE('has_region').from(a5).to(ind)
g.addE('has_region').from(a5).to(usa)
1

1 Answers

0
votes

It seems I can use the "is" step to filter scalars

g.V(2).repeat(out().not(hasLabel('region', 'business')).simplePath()).until(outE().count().is(0))
g.V(2).repeat(out().not(hasLabel('region', 'business')).simplePath()).until(outE().count().is(gt(5)))