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),
(hugo:Person)
WHERE keanu.name='Keanu Reeves' AND
hugo.name='Hugo Weaving'
AND NOT (hugo)-[:ACTED_IN]->(movie)
RETURN n.name

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.name='Keanu Reeves' AND
NOT n.name='Hugo Weaving'
RETURN DISTINCT n.name

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.

Elaine

1 Like

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