Here is what I am trying, right off the DSL web page and it does not work.. can someone just try and run this? Maybe my neo environment is messed up..
This is taken right from the examples located here:
Dijkstra Single-Source Shortest Path - Neo4j Graph Data Science
Create Graph:
CREATE (a:Location {name: 'A'}),
(b:Location {name: 'B'}),
(c:Location {name: 'C'}),
(d:Location {name: 'D'}),
(e:Location {name: 'E'}),
(f:Location {name: 'F'}),
(a)-[:ROAD {cost: 50}]->(b),
(a)-[:ROAD {cost: 50}]->(c),
(a)-[:ROAD {cost: 100}]->(d),
(b)-[:ROAD {cost: 40}]->(d),
(c)-[:ROAD {cost: 40}]->(d),
(c)-[:ROAD {cost: 80}]->(e),
(d)-[:ROAD {cost: 30}]->(e),
(d)-[:ROAD {cost: 80}]->(f),
(e)-[:ROAD {cost: 40}]->(f);
Yields
(Image would not load but it looks great!)
Lets look at the details:
match (scr)-[r:ROAD]-(dest) return scr.name, r.cost, dest.name
╒════════╤══════╤═════════╕
│scr.name│r.cost│dest.name│
╞════════╪══════╪═════════╡
│"E" │40 │"F" │
├────────┼──────┼─────────┤
│"F" │40 │"E" │
├────────┼──────┼─────────┤
│"A" │50 │"B" │
├────────┼──────┼─────────┤
│"B" │50 │"A" │
├────────┼──────┼─────────┤
│"A" │50 │"C" │
├────────┼──────┼─────────┤
│"C" │50 │"A" │
├────────┼──────┼─────────┤
│"A" │100 │"D" │
├────────┼──────┼─────────┤
│"D" │100 │"A" │
├────────┼──────┼─────────┤
│"B" │40 │"D" │
├────────┼──────┼─────────┤
│"D" │40 │"B" │
├────────┼──────┼─────────┤
│"C" │80 │"E" │
├────────┼──────┼─────────┤
│"E" │80 │"C" │
├────────┼──────┼─────────┤
│"C" │40 │"D" │
Project Graph
MATCH (source:Location)-[r:ROAD]->(target:Location)
RETURN gds.graph.project(
'myGraph',
source,
target,
{ relationshipProperties: r { .cost } }
)
Yields the Following:
{
"relationshipCount": 9,
"graphName": "myGraph",
"query": "MATCH (source:Location)-[r:ROAD]->(target:Location)
RETURN gds.graph.project(
'myGraph',
source,
target,
{ relationshipProperties: r { .cost } }
)",
"projectMillis": 108,
"configuration": {
"readConcurrency": 4,
"undirectedRelationshipTypes": ,
"jobId": "ed99ff17-e543-43d2-b340-0e8a3b1ca371",
"logProgress": true,
"query": "MATCH (source:Location)-[r:ROAD]->(target:Location)
RETURN gds.graph.project(
'myGraph',
source,
target,
{ relationshipProperties: r { .cost } }
)",
"inverseIndexedRelationshipTypes": ,
"creationTime": "2024-10-03T13:22:08.120852200Z"
},
"nodeCount": 6
}
Streaming Results
( I tried skipping this step does not seem to matter, inclluding it causes problems on the write out of the inMemory graph)
MATCH (source:Location {name: 'A'})
CALL gds.allShortestPaths.dijkstra.stream('myGraph', {
sourceNode: source,
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
Mutate the InMemory Graph
This will perform the shortest path calculations on the inMemory Graph called myGraph..
MATCH (source:Location {name: 'A'})
CALL gds.allShortestPaths.dijkstra.mutate('myGraph', {
sourceNode: source,
relationshipWeightProperty: 'cost',
mutateRelationshipType: 'PATH'
})
YIELD relationshipsWritten
RETURN relationshipsWritten
Yeilds
6 relationship written, seems to have worked.. now.. lets write this back to our actual graph so we can look at it..
Write InMemory to Master Graph
MATCH (source:Location {name: 'A'})
CALL gds.allShortestPaths.dijkstra.write('myGraph', {
sourceNode: source,
relationshipWeightProperty: 'cost',
writeRelationshipType: 'PATH',
writeNodeIds: true,
writeCosts: true
})
YIELD relationshipsWritten
RETURN relationshipsWritten
Yields
Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure gds.allShortestPaths.dijkstra.write
: Caused by: java.lang.IllegalArgumentException: Relationship weight property cost
not found in relationship types ['PATH']. Properties existing on all relationship types: []
Any Ideas..