Variable length traversal
Actors 2 hops away from Robert Blake.
Update this query to return the names of actors that are 2 hops away from Robert Blake using the ACTED_IN relationship.
cypher
MATCH (p:Person {name: 'Robert Blake'})-[:ACTED_IN??]-(others:Person)
RETURN others.name
How many actors are returned in the result?
-
✓ 12
Hint
Use the :ACTED_IN*2
specification for the relationship.
Solution
The answer is 12
.
Run the following query to see the result:
cypher
MATCH (p:Person {name: 'Robert Blake'})-[:ACTED_IN*2]-(others:Person)
RETURN others.name
Summary
In this challenge, you wrote a query that uses varying length paths.
In the next challenge, you will write another query.