I'm using a database from a particular Udemy course. When I run MATCH (x)--(y)-->(z) RETURN x, y, z LIMIT 2 I get
and when I run MATCH (x)--(y)-->(z) RETURN x, y, z LIMIT 3 (2 -> 3) I get
As I see it, there are already three, non-repeat instances of (x)--(y)-->(z) in the first diagram—see my graphical annotation—so I don't understand why Neo4j sees the need to add more nodes for the second query. Obviously this means that I don't understand Cypher semantics; I would appreciate it if you would replace my incorrect understanding with a correct one.
When you show the results as a graph in the browser, it seems neo4j shows the nodes that result and all the connections among those nodes. Try viewing your results using the 'text' or 'table' renderings. You will probably be shown the proper number of paths.
Not sure what you're saying, but it looks like you're saying that it would make the x, y, z triples that are matched explicit? It might not dispel my doubts, but it's a good idea; will do
The graph rendering seems to show all the nodes that resulted from your query, and displays them will all their connections, regardless if they are part of your result.
The text and table renderings show the explicit result by row; therefore, you should see two results in your first query and three results in the second. If you want to see the connections between them too, you could write the query to return the paths instead of the individual nodes, such as:
@glilienfield I guess there's a rule that any match to a MATCH query must consist of at least one component (node or relationship) that doesn't form part of the other matches?
You did not put any constraints on the nodes, so it gave you the first three paths it determined. I just so happens that these paths consisted collectively of 5 nodes. There must be many paths in this data set to choose from. It wasn't guaranteed that you would have gotten the three paths you highlighted in your first diagram, since they are more than three in your dataset. You could get those three if you constrained your node y to be Keanu Reeves (again, assuming there are not more paths traversing through Keanu Reeves)
Add a SKIP clause, and you will get a different set of three paths (assuming you have 6 or paths)
MATCH p = (x)--(y)-->(z)
RETURN return p
SKIP 3
LIMIT 3
there is no constraint imposed between the results. Each just has to meet the conditions of the query. Try removing the LIMIT clause, so you see all paths that meet your match pattern.