I have a working query, that returns all the co actors of Tom Hanks (basically a friend of a friend problem).
SELECT COUNT(name) as name FROM (
SELECT expand(out('ACTS_IN').in('ACTS_IN')) FROM Actor WHERE name = 'Tom Hanks'
) WHERE name <> 'Tom Hanks'
Now I'm trying to construct a query that would give me co actors of co actors (friends of friends of friend)
My query, that doesn't finish
SELECT count(DISTINCT(name)) as coactor FROM (
SELECT expand(out('ACTS_IN').in('ACTS_IN').out('ACTS_IN').in('ACTS_IN').out('ACTS_IN').in('ACTS_IN')) FROM Person WHERE name = 'Tom Hanks'
)
WHERE name <> 'Tom Hanks'
The question is, can you stack .in and .out like this:
expand(out('ACTS_IN').in('ACTS_IN').out('ACTS_IN').in('ACTS_IN').out('ACTS_IN').in('ACTS_IN'))
In your case you could use the
TRAVERSE()
function to retrieve all the records linked by the edgeACTS_IN
.Structure:
Query 1: Retrieve all of the actors/co-actors/ecc... of 'Tom Hanks' (except himself)
Query 2: Retrieve the count of the actors/co-actors/ecc... of 'Tom Hanks' (except himself)