apoc.algo.dijkstra

Details

Syntax

apoc.algo.dijkstra(startNode, endNode, relTypesAndDirections, weightPropertyName [, defaultWeight, numberOfWantedPaths ]) :: (path, weight)

Description

Runs Dijkstra’s algorithm using the given RELATIONSHIP property as the cost function.

Input arguments

Name

Type

Description

startNode

NODE

The node to start the search from.

endNode

NODE

The node to end the search on.

relTypesAndDirections

STRING

The relationship types to restrict the algorithm to. Relationship types are represented using APOC’s rel-direction-pattern syntax; [<]RELATIONSHIP_TYPE1[>]|[<]RELATIONSHIP_TYPE2[>]|…​.

weightPropertyName

STRING

The name of the property to use as the weight.

defaultWeight

FLOAT

The defaultWeight is used when no specific weight is provided for the given relationship or node. The default value for defaultWeight is NaN. The default is: NaN.

numberOfWantedPaths

INTEGER

The number of wanted paths to return. The default is: 1.

Return arguments

Name

Type

Description

path

PATH

The path result.

weight

FLOAT

The weight of the given path.