Précisions exercice 2

This commit is contained in:
2025-10-27 07:49:35 +01:00
parent f9f9c9e4bc
commit ce7a050242

View File

@@ -60,11 +60,28 @@ MATCH (p:Point) DETACH DELETE p;
2. Quel est le plus court chemin entre le casino et la falaise 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) ![](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 ## Réseau d'amis