Drop graph after computation
27 AS person2Id
}
*/
-CALL gds.graph.drop('q14graph', false)
-YIELD graphName
-
-// ----------------------------------------------------------------------------------------------------
-WITH count(*) AS dummy
-// ----------------------------------------------------------------------------------------------------
-
// Check whether a path exists -- if there is no path, the query will return an empty result
MATCH
path = shortestPath((person1 {id: $person1Id})-[:KNOWS*]-(person2 {id: $person2Id}))
@@ -25,7 +18,7 @@ WITH 42 AS dummy
MATCH (person1:Person {id: $person1Id}), (person2:Person {id: $person2Id})
CALL gds.graph.project.cypher(
- 'q14graph',
+ apoc.create.uuidBase64(),
'MATCH (p:Person) RETURN id(p) AS id',
'MATCH
(pA:Person)-[knows:KNOWS]-(pB:Person),
@@ -43,13 +36,18 @@ CALL gds.graph.project.cypher(
YIELD graphName
// ----------------------------------------------------------------------------------------------------
-WITH person1, person2
+WITH person1, person2, graphName
// ----------------------------------------------------------------------------------------------------
CALL gds.shortestPath.dijkstra.stream(
- 'q14graph', {sourceNode: person1, targetNode: person2, relationshipWeightProperty: 'weight'}
+ graphName, {sourceNode: person1, targetNode: person2, relationshipWeightProperty: 'weight'}
)
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
+WITH path, totalCost, graphName
+
+CALL gds.graph.drop(graphName, false)
+YIELD graphName as graphNameremoved
+
RETURN [person IN nodes(path) | person.id] AS personIdsInPath, totalCost AS pathWeight
LIMIT 1
