By reading the official Neo4j documentation, I can't understand what does the two parameters limit
and maxLevel
mean in a apoc.path.subgraphnodes
.
https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/path-finding/path-expander/
Anyone can help me ?
Thanks in advance
maxLevel
is basically the depth of the expansion. maxLevel:2
means up to two expansions from the starting node.
limit
limits the total results returned from the call, once this many results are found, then it will stop looking further.
So as an example, if we had a social graph, and you wanted to find the first 3 :Doctor nodes, within 10 expansions of you (this uses breadth first expansion by default), you might use something like:
MATCH (me:Person {id:12345})
CALL apoc.path.subgraphNodes(me, {maxLevel:10, limit:3, labelFilter:'Doctor'}) YIELD node
RETURN node
And there might be thousands of :Doctor nodes within 10 hops, but because of the limit:3
, once 3 are found it will stop trying to find more.