Run the query set in the first order in parallel, one from each path to the beginning of the node, and each time you examine the node, increase its number by one. (Note: “Parallel” here means that you must first perform all estimates of “distance = 1” for all searches, then all “distance = 2”, etc. - this ensures that the result you find is the closest any way). Make sure you do not run cycles on the chart, if they exist.
Stop at the first node, you increase the counter, which matches the number of out-paths from the original node.
Runtime is O (N + E), where N is the number of nodes, and E is the number of edges below the current node. Most requests will take less time due to early completion.
Amber
source share