This was the query from the previous video.
MATCH path1 = (p1:Project {name: "tqdm"}) --> (p2:Project)
OPTIONAL MATCH path2 = (p2) -[*1..4]-> (other: Project)
RETURN path1, path2
It works, but it deserves refactoring. This might be better:
MATCH path = (p1:Project {name: "tqdm"}) -[*1..4]-> (p2:Project)
RETURN p1, p2, path
Refactoring might be a thing you end up doing more frequently than you might if you were using SQL. That's because graphs tend to be more elaborate data structures and because there are multiple ways of asking for the same data.
We can expand the query a bit further though to look for all
the dependencies of tqdm
.
MATCH path = (p1:Project {name: "tqdm"}) -[*0..]-> (other:Project)
RETURN p1, other, path
LIMIT 100
It's wise to add a limit to the query here. We've removed the upper limit on path lengths and which means that we might be asking for a lot of paths.
Note
After reviewing the video, we figure this query to be better:
MATCH path = (p1:Project {name: "tqdm"}) -[*1..]-> (other:Project)
RETURN p1, other, path
LIMIT 100
We're not interested in paths of length zero.