Date
1 - 4 of 4
filtering a path
yair...@...
What's the best way to filter a path based on a Vertex property. I am using the gremlin-scala lib. This is the code: val paths = startVertex.asScala().start() .repeat(_.outE().inV().simplePath()) .until(_.is(endVertex.vertex)) .path() .toList() This works great. Now I want to add a filter that will filter out any Vertexes (even those in between start and end) in the path where property("num") > 50. Seems that the filter API is only for the End Vertex? |
|
Daniel Kuppitz <me@...>
even those in between start and end Does that mean you want to exclude the whole path or only matching vertices on the path? If the latter, then what about the edges? Taking out a single vertex leaves 2 invalid edges on the path. If the former, then it's:
Cheers, Daniel On Wed, Aug 30, 2017 at 6:34 AM, <yair...@...> wrote:
|
|
Yair Ogen <yair...@...>
That didn't compile. I changed it to use Key: .repeat(_.outE().inV().has(Key[Long]("num"),gt(50)).simplePath()) oddly enough it filters everything although clearly some ages do have higher than 50 in this property |
|
Daniel Kuppitz <me@...>
I don't know how to write Scala code, so you'll always have to convert my code snippets from Java to Scala ;). Again, the snippet assumes, that all vertices on a certain path have a num value greater than 50. If that's not what you want, then how do you want to treat edges that are connected to vertices that don't match the filter criteria? Let me demonstrate the problem. Let's say you want to find all paths in the modern graph, that end at v[1]:
Another way to do that would be:
Using this approach, you can filter out certain vertices (e.g. you only want person vertices):
As you can see, that keeps some edges, that no longer make any sense. Cheers, Daniel On Wed, Aug 30, 2017 at 7:14 AM, Yair Ogen <yair...@...> wrote:
|
|