Skip to content

Commit ff48238

Browse files
committed
Cypher: Only run Q14 cheapest path algorithm if a path (any path) exists
1 parent 9af1c9e commit ff48238

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cypher/queries/interactive-complex-14.cypher

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
27 AS person2Id
77
}
88
*/
9-
CALL gds.graph.drop('q14graph', false)
10-
YIELD graphName
9+
// Check whether a path exists -- if there is no path, the query will return an empty result
10+
MATCH
11+
(person1:Person {id: $person1Id}),
12+
(person2:Person {id: $person2Id}),
13+
path = shortestPath((person1)-[:KNOWS*]-(person2))
1114

1215
// ----------------------------------------------------------------------------------------------------
13-
WITH count(*) AS dummy
16+
WITH path
1417
// ----------------------------------------------------------------------------------------------------
1518

1619
CALL gds.graph.project.cypher(

0 commit comments

Comments
 (0)