neo4j-contrib / neo4j-graph-algorithms

Efficient Graph Algorithms for Neo4j
https://github.com/neo4j/graph-data-science/
GNU General Public License v3.0
769 stars 195 forks source link

algo.shortestPath requires weightProperty as mandatory #840

Closed umuzammil closed 5 years ago

umuzammil commented 5 years ago

Doc: https://neo4j.com/docs/graph-algorithms/3.5/algorithms/shortest-path/#algorithms-shortest-path-syntax lists weightProperty as optional, but f omitted, it throws the following exception.

Reproduced locally on the movies database Neo4j Enterprise 3.5.3 Algo 3.5.3.1

match (a:Person{name:'Tom Hanks'}),(b:Person{name:'Keanu Reeves'}) 
call algo.shortestPath(b, a) 
YIELD nodeCount 
RETURN nodeCount

results in:

Neo.ClientError.Statement.SyntaxError: Procedure call does not provide the required number of arguments: got 3 expected 4.
Procedure algo.shortestPath has signature: algo.shortestPath(startNode :: NODE?, endNode :: NODE?, propertyName :: STRING?, config = {} :: MAP?) :: loadMillis :: INTEGER?, evalMillis :: INTEGER?, writeMillis :: INTEGER?, nodeCount :: INTEGER?, totalCost :: FLOAT?
meaning that it expects 4 arguments of type NODE?, NODE?, STRING?, MAP?
Description: CALL algo.shortestPath(startNode:Node, endNode:Node, weightProperty:String{nodeQuery:'labelName', relationshipQuery:'relationshipName', direction:'BOTH', defaultValue:1.0, write:'true', writeProperty:'sssp'}) YIELD nodeId, cost, loadMillis, evalMillis, writeMillis - yields nodeCount, totalCost, loadMillis, evalMillis, writeMillis (line 2, column 1 (offset: 68))
"call algo.shortestPath(b, a) "

whereas executing with weight as:

call algo.shortestPath(b, a, 'weight') 
YIELD nodeCount 
RETURN nodeCount

gives a result of nodeCount = 5. Is the documentation incorrect or the algo behaviour?

umuzammil commented 5 years ago

hey guys, any updates?

s1ck commented 5 years ago

It should be optional as described. I will open a PR.

umuzammil commented 5 years ago

Thanks!

s1ck commented 5 years ago

In https://github.com/neo4j-contrib/neo4j-graph-algorithms/pull/869 we moved the weight property into the params list. However, this breaks the procedure API for existing users. There is still a fix contained in https://github.com/neo4j-contrib/neo4j-graph-algorithms/commit/2806408c9120b4675451a362e4e04f3aa3b17ac7 that allows you to just specify source and target without weight property and params. Hope that helps.

umuzammil commented 5 years ago

Tested in version 3.5.4.3. Works fine. Thanks!!