Help converting examples to GDS library

How can I find out how to convert the Cypher examples using the Graph Algorithms library to using the new GDS library?

So far I have the GDS library installed in Neo4j 3.5.17 using Neo4j Desktop 1.2.6. I could not figure out how to install GDS with Neo4j 4.0.3. Reading through the discussions here makes me think I should be moving forward with the Graph Data Science library instead of trying to solve the library installation problem I have with the earlier Graph Algorithms library.

When I try this example from the book with my own guesswork conversion to use GDS,

MATCH (source:Place {id: "Amsterdam"}), (destination:Place {id: "London"})
CALL gds.alpha.shortestPath.stream(source, destination, null) YIELD nodeId, cost
RETURN gds.getNodeById(nodeId).id AS place, cost

I get this error,

Procedure call provides too many arguments: got 3 expected no more than 2.

Procedure gds.alpha.shortestPath.stream has signature: gds.alpha.shortestPath.stream(graphName :: ANY?, configuration  =  {} :: MAP?) :: nodeId :: INTEGER?, cost :: FLOAT?
meaning that it expects at least 1 argument of type ANY?
Description: The Shortest Path algorithm calculates the shortest (weighted) path between a pair of nodes using the Dijkstra algorithm. (line 1, column 81 (offset: 80))
"MATCH (source:Place {id: "Amsterdam"}),
(destination:Place {id: "London"})
CALL gds.alpha.shortestPath.stream(source, destination, null) YIELD nodeId, cost
RETURN gds.getNodeById(nodeId).id AS place, cost"

I am sure I will get better at understading Cypher error messages but until then if anyone can suggest what I need to do or understand to use GDS that would be great!

We have a migration guide here: Migration from Graph Data Science library Version 1.x - Neo4j Graph Data Science

It explains how to convert the syntax from the graph algorithms library over to the GDS.

For the book specifically, the fabulous @tomaz.bratanic published a blog post that detailed converting the graph algorithms from the book to GDS: Preview of the Neo4j Graph Data Science plugin with examples from the “Graph Algorithms: Practical Examples in Apache Spark and Neo4j” book | by Tomaz Bratanic | Towards Data Science

1 Like

Many thanks! Tomaz's article looks very useful.

Are there plans for a Neo4j only GDS version of the book?

We've just recently updated the book so it uses the Syntax from the GDS library -- you should be able to download an updated copy here: Neo4j Graph Data Science | Graph Algorithms and ML | Graph Analytics