Graph Academy 2MATCH patterns

In graphacademy/online-training/ Part 5 . we retrieve the actors who acted in the same movies as Keanu Reeves , but not when Hugo Weaving acted in the same movie.

MATCH (keanu:Person)-[:ACTED_IN]->(movie:Movie)<-[:ACTED_IN]-(n:Person),
WHERE'Keanu Reeves' AND'Hugo Weaving'
AND NOT (hugo)-[:ACTED_IN]->(movie)

This query witch return 10 ACTORS. I thought my query was equivalent :

MATCH (keanu:Person)-[:ACTED_IN]->(movie:Movie)<-[:ACTED_IN]-(n:Person)
WHERE'Keanu Reeves' AND
NOT'Hugo Weaving'

But it returns 13 row. And I don' t see the difference in the query . Can someone explain what i'm missing? THX

Hello and welcome to the community!

Your query excludes Hugo Weaving, but it does not exclude the paths from the movies that Hugo acted in so for example, you query will return actors who acted in the same movies as Hugo Weaving.


1 Like

Great explanation!
Now i see that i must be more focused on excluding relation vs the exclusion of some results.