cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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?

1 ACCEPTED SOLUTION

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/...

(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).

View solution in original post

1 REPLY 1

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/...

(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).