0
votes

I'm learning Neo4j and playing around with the movie graph in a browser. Following a tutorial, I extract a subgraph around Tom Hanks with the following query:

MATCH (a {name: "Tom Hanks"})-[:ACTED_IN]->(m)<-[:DIRECTED]-(d) RETURN a,m,d LIMIT 10;

As expected, this displays a subgraph of Tom Hanks, ten nodes representing movies he acted in, and the directors of each movie. Wanting to know what the subgraph looks like when not limited to 10 movies, I tried running:

MATCH (a {name: "Tom Hanks"})-[:ACTED_IN]->(m)<-[:DIRECTED]-(d) RETURN a,m,d;

For reasons I don't understand, this produces 3 copies of the expected subgraph, as shown below. Can anyone explain why this happens, and what would be the correct command to display the expected graph? enter image description here

1
Do you have three copies of the subgraph? I would print the node Ids to verify.Cameron Tinker

1 Answers

3
votes

It looks like you may have run the CREATE script multiple times before deleting the database. If you are just using the data from the :PLAY movies example, then what you can do is remove all of the data using:

MATCH (n) DETACH DELETE n

And then run the browser guide again to add the data set.

Once you're feeling comfortable with the movies guide, perhaps you can learn more about the different ways to create Nodes and Relationships in Neo4j. Check this page out, and the associated topics under "Cypher Query Language" menu on the left