How to use a Stored Graph in Graph Catalog in Dijkstra Source-Target Algorithm

Hello
I created a graph using graph generator algorithm as follow:

CALL gds.beta.graph.generate('test', 3, 2, { relationshipDistribution : 'random', relationshipProperty: { name:',cost', type: 'RANDOM', min : 40.0, max : 80.0 } }) YIELD name, nodes, relationships, generateMillis, relationshipSeed, averageDegree, relationshipDistribution, relationshipProperty

Here a graph named test is created and stored in the graph catalog. As depicted in Link_1, the generated graph can be used as input for any algorithm in the library.
Now to use the generated graph in Dijkstra Source-Target Algorithm, I run the following cypher:

MATCH (source:host {name: 'node_1'}), (target:host {name: 'node_2'}) CALL gds.shortestPath.dijkstra.stream('myGraph', { sourceNode: source, targetNode: target, relationshipWeightProperty: 'cost' }) YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path RETURN index, gds.util.asNode(sourceNode).name AS sourceNodeName, gds.util.asNode(targetNode).name AS targetNodeName, totalCost, [nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS nodeNames, costs, nodes(path) as path ORDER BY index

How can I set the node names in the generated graph to be used as Source-Target in the Dijkstra Algorithm?

Just for reference, this was also posted to our Github page, and the engineering team has responded: How to use a Stored Graph in Graph Catalog in Dijkstra Source-Target Algorithm · Issue #127 · neo4j/graph-data-science · GitHub

(TL;DR - the source/target nodes in the random graph don't have names; you can run djikstra by specifying node IDs, but there's no guarantee two nodes will be connected).

1 Like