java - Match NOT in Tinkerpop traversal -
i'd match b1, no node b2 exists depicted below.
kind of 2-hop asymmetry. note non-existent b2 must link same c:c b1, other (a2) --> (b3) --> (a1) can ignored long b3 has no edge c:c.
i tried following...
graph.traversal().v() .match( as("c").haslabel("c"), as("a").haslabel("a") .out().haslabel("b").as("b1") .where(out().as("c")) .out().haslabel("a").as("a2"), not( as("a2") .out().haslabel("b").as("b2") .where(out().as("c") .out().as("a1") ) ) ...but second match step throws exception:
java.lang.illegalstateexception: provided match pattern unsolvable: [[matchstartstep(a1), hasstep([~label.eq(a)]), vertexstep(out,vertex), hasstep([~label.eq(b)]), wheretraversalstep([wherestartstep, vertexstep(out,vertex), whereendstep(c)])@[b1], vertexstep(out,vertex), hasstep([~label.eq(a)]), matchendstep(a2)], [matchstartstep(a2), hasstep([~label.eq(b)]), wheretraversalstep([notstep([wherestartstep, vertexstep(out,edge)])]), wheretraversalstep([wherestartstep, vertexstep(out,vertex)@[c], vertexstep(out,vertex), whereendstep(a1)])@[b2], matchendstep, matchendstep]] i can't match cypher, unfortunately.
suddenly, found solution avoids scope problems:
graph.traversal().v() as("a").haslabel("a") .out().haslabel("b").as("b1") .where(out().haslabel("c")) .out().haslabel("a").as("a2") .where( not( out().haslabel("b") .where(out().haslabel("c")) .out().as("a") ) )
Comments
Post a Comment