I need to fix an issue i am facing.
simply put, i need to select 500 random nodes and count the number of paths to a single target node at hops 1,2,3,4. i am doing it one at a time after coming up with those random nodes using a separate code. this means i have to run the count 500 times and it is time consuming.
match (n:random), (m:not random)
with n, collect(m) as terminatorNodes CALL apoc.path.expandConfig(n, {
relationshipFilter:">",
minLevel: 1,
maxLevel: 4,
terminatorNodes:terminatorNodes,
uniqueness: "NODE_PATH"
}) yield path
with count (path) as number_of_paths, (length(path)) as number_of_hops WITH collect ({number_of_hops:number_of_hops,
number_of_paths:number_of_paths}) as rows, max(number_of_hops) as maxHops
UNWIND range(1, 4) as number_of_hops
RETURN number_of_hops, coalesce([row IN rows WHERE row.number_of_hops = number_of_hops][0]. number_of_paths,0) as number_of_paths