Actors Up to 4 Hops Away

Variable length traversal

Actors up to 4 hops away from Robert Blake.

Update this query to return the unique names of actors that are up to 4 hops away from Robert Blake using the ACTED_IN relationship.

cypher
MATCH (p:Person {name: 'Robert Blake'})-[??????]-(others:Person)
RETURN DISTINCT others.name

How many unique actors are returned in the result?

  • ✓ 263

Hint

Use the :ACTED_IN*1..4 specification for the relationship.

Solution

The answer is 263.

Run the following query to see the result:

cypher
MATCH (p:Person {name: 'Robert Blake'})-[:ACTED_IN*1..4]-(others:Person)
RETURN DISTINCT others.name

Summary

In this challenge, you answered a question about a query with a varying length paths.

In the next module, you will learn about pipelining queries.