Actors 4 Hops Away

Variable length traversal

Actors 4 hops away from Robert Blake.

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

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

How many actor names are returned in the result?

  • ✓ 253

Hint

Use the :ACTED_IN*4 specification for the relationship.

You can use DISTINCT to filter out duplicate results.

Solution

The answer is 253.

Run the following query to see the result:

cypher
MATCH (p:Person {name: 'Robert Blake'})-[:ACTED_IN*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 challenge, you will write another query.