66 27 AS person2Id
77}
88*/
9- CALL gds .graph .drop ('q14graph' , false )
10- YIELD graphName
11-
12- // ----------------------------------------------------------------------------------------------------
13- WITH count (* ) AS dummy
14- // ----------------------------------------------------------------------------------------------------
15-
169// Check whether a path exists -- if there is no path, the query will return an empty result
1710MATCH
1811 path = shortestPath ((person1 { id : $person1Id } )- [ : KNOWS * ] - (person2 { id : $person2Id } ))
@@ -25,7 +18,7 @@ WITH 42 AS dummy
2518
2619MATCH (person1 :Person { id : $person1Id } ), (person2 :Person { id : $person2Id } )
2720CALL gds .graph .project .cypher (
28- 'q14graph' ,
21+ apoc . create . uuidBase64 () ,
2922 'MATCH (p:Person) RETURN id(p) AS id' ,
3023 'MATCH
3124 (pA:Person)-[knows:KNOWS]-(pB:Person),
@@ -43,13 +36,18 @@ CALL gds.graph.project.cypher(
4336YIELD graphName
4437
4538// ----------------------------------------------------------------------------------------------------
46- WITH person1 , person2
39+ WITH person1 , person2 , graphName
4740// ----------------------------------------------------------------------------------------------------
4841
4942CALL gds .shortestPath .dijkstra .stream (
50- 'q14graph' , { sourceNode : person1 , targetNode : person2 , relationshipWeightProperty : 'weight' }
43+ graphName , { sourceNode : person1 , targetNode : person2 , relationshipWeightProperty : 'weight' }
5144)
5245YIELD index , sourceNode , targetNode , totalCost , nodeIds , costs , path
5346
47+ WITH path , totalCost , graphName
48+
49+ CALL gds .graph .drop (graphName , false )
50+ YIELD graphName as graphNameremoved
51+
5452RETURN [person IN nodes (path ) | person .id ] AS personIdsInPath , totalCost AS pathWeight
5553LIMIT 1
0 commit comments