From ce7a050242bb22ab8920319e6f9ed5bafc7e94ab Mon Sep 17 00:00:00 2001 From: medina5 Date: Mon, 27 Oct 2025 07:49:35 +0100 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9cisions=20exercice=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercice2.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/exercice2.md b/exercice2.md index 2ca04c7..73fb37b 100644 --- a/exercice2.md +++ b/exercice2.md @@ -60,11 +60,28 @@ MATCH (p:Point) DETACH DELETE p; 2. Quel est le plus court chemin entre le casino et la falaise -a. Un chemin comportant au maximum 10 segments (mais ce n'est pas le plus court !) +a. Un chemin comportant au maximum 8 segments (mais ce n'est pas le plus court !) ![](route.png) +Utilisation de la fonction dijkstra de la bibliothèque GDS +[49, 54, 46, 28, 45, 24, 23, 13, 6, 7, 2, 1, 8, 9, 18, 19, 20, 57, 21, 31, 38, 39, 40, 58] + +```cypher +MATCH (source:Point {id: 49}), (target:Point {id: 58}) +CALL gds.shortestPath.dijkstra.stream('routes_graph', { + sourceNode: source, + targetNode: target, + relationshipWeightProperty: 'cout' +}) +YIELD nodeIds, totalCost +UNWIND range(0, size(nodeIds)-2) AS i +MATCH (n1) WHERE id(n1) = nodeIds[i] +MATCH (n2) WHERE id(n2) = nodeIds[i+1] +MATCH path = (n1)-[r:ROUTE]->(n2) +RETURN collect(path) AS chemin, totalCost; +``` ## Réseau d'amis