Testing Patterns

Rob Reiner directed

Find the movies that "Rob Reiner" directed, but did not act in.

Update the query to test for the existence of a pattern where "Rob Reiner" acted in a movie.

cypher
MATCH (p:Person)-[:DIRECTED]->(m:Movie)
WHERE p.name = 'Rob Reiner'
AND NOT ?????? {(?)-[:??????]->(?)}
RETURN DISTINCT m.title

How many rows are returned?

  • ✓ 14

Hint

Use NOT exists {<pattern>}. The pattern should use the p and m nodes.

Solution

The answer is 14

You can run the following query to see the result:

cypher
MATCH (p:Person)-[:DIRECTED]->(m:Movie)
WHERE p.name = 'Rob Reiner'
AND NOT exists {(p)-[:ACTED_IN]->(m)}
RETURN DISTINCT m.title

Summary

In this challenge, you tested patterns in the graph.

In the next challenge, you will profile a query.