0
votes

How to stop traversing after edge class?

The graph for the query TRAVERSE bothE(), bothV() FROM ( SELECT FROM Title WHERE title_id IN [12] ) looks like this:

Relation graph example

If I wrote (for blue graph):

TRAVERSE bothE("E14", "E5", "E6"), bothV() FROM ( SELECT FROM Title WHERE title_id IN [12] )

it don't gave me V 970.

How to construct a query that will return the part I need? I would like the whole graph to be returned if there exists an orange route.

I tested: TRAVERSE inE(..), outE(...), bothE() and WHILE $parent.$current.@class != "E13" bit it don't works.

I've seen https://stackoverflow.com/a/43776591/1194525, but if I understand correctly, MATCH can be used at a well known well.

1
Hi, what's the expected result? Thx - Michela Bonizzi
could you attach a db export for testing? - Ivan Mainetti
DB export: app.box.com/s/m624p6nf04njj2vjsxtwn3h268ugm864 Expected result: blue, without red and orange. (One piece group + Dragon Ball Z, without other Dragon Ball's). E13 - is Character relation - bato3
How about SELECT expand(both()) FROM Title WHERE title_id IN [12] ? - Ivan Mainetti
In this case yes, but generally NO. (And it don't gave me Edges) Your query equivalent to TRAVERSE bothE(), bothV() FROM ( SELECT FROM Title WHERE title_id IN [12] ) WHILE $depth <=2 - bato3

1 Answers

0
votes

I have an idea how to do it in 2 queries, but could use improvement, eg .: Doing this in 1 query.

step 1: Traverse graph by all "right" edges.

TRAVERSE bothE("Prequel", "Sequel"), bothV() FROM (
  SELECT FROM Title WHERE title_id IN [12] )

step 2: Get all Vertex rid from response (in client)

step 3: Query by "stop" edges for all Vertex rid from previous query.

TRAVERSE bothE("Character"), bothV() FROM (
  SELECT FROM Title WHERE title_id IN [12, 431, 432, 433, ...] )
  MAXDEPTH 2

step 4: Merge responses (Vertex + Edges) in client.