Skip to main content
The algo.SPpaths procedure finds the shortest paths between a source and a target node, optionally constrained by cost, path length, and the number of paths to return. It is designed for efficient and scalable computation of paths in large graphs, using properties like distance, time, or price as weights. For example, it can be used to find the fastest driving route between two cities, the cheapest shipping option in a logistics network, or the shortest communication path in a computer network.

Syntax

Parameters

Returns

Examples

Let’s take this Road Network Graph as an example: Road network

Example: Shortest Path by Distance from City A to City G

Expected Result:

Example: Bounded Cost Path from City A to City G

Expected Result:


Frequently Asked Questions

weightProp is the property the algorithm minimizes (e.g. distance). costProp is a separate property used as a constraint — you can set maxCost to exclude paths whose total cost exceeds a threshold.
Set pathCount: 0 to return all shortest paths. The default is 1 (single shortest path). You can also set a specific number like pathCount: 5 to get up to 5 paths.
Yes. Set relDirection to 'both' to traverse relationships regardless of direction. Other options are 'outgoing' (default) and 'incoming'.
Use algo.SPpaths when you have a specific source and target node. Use algo.SSpaths when you want shortest paths from one source to all reachable destinations.
The procedure returns no results (empty result set). No error is raised.