```shell docker compose up -d ``` Rendez vous ensuite à l'adresse : http://localhost:7474 ## Réseau routier ### Charger les données Les points ```cypher LOAD CSV WITH HEADERS FROM 'file:///points.csv' AS row MERGE (p:Point { id: toInteger(row.id) }) SET p.nom = row.nom, p.altitude = toInteger(row.altitude), p.location = point({ longitude: toFloat(row.longitude), latitude: toFloat(row.latitude) }); ``` Les routes entre les points ``` LOAD CSV WITH HEADERS FROM 'file:///routes.csv' AS row WITH row MATCH (a:Point {id: toInteger(row.source)}) WITH a, row MATCH (b:Point {id: toInteger(row.target)}) MERGE (a)-[r:ROUTE {route_id: toInteger(row.route_id)}]->(b) SET r.tag = row.tag, r.cout = toFloat(row.cout); ``` les routes inverses si cout_inverse est différent de -1 ``` LOAD CSV WITH HEADERS FROM 'file:///routes.csv' AS row WITH row WHERE toFloat(row.cout_inverse) <> -1 MATCH (a:Point {id: toInteger(row.source)}) WITH a, row MATCH (b:Point {id: toInteger(row.target)}) MERGE (b)-[r:ROUTE {route_id: toInteger(row.route_id) * 1000}]->(a) SET r.tag = row.tag, r.cout = toFloat(row.cout_inverse); ``` Supprimer les points et les routes. ```sql MATCH (p:Point) DETACH DELETE p; ``` ### Questions 1. Quelle est la distance entre le casino et la falaise Indice : 2895 m 2. Quel est le plus court chemin entre le casino et la falaise a. Un chemin comportant au maximum 8 segments (mais il ne prend pas en compte les coûts, ce n'est pas le plus rapide !) ![](route.png) Utilisation de la fonction dijkstra de la bibliothèque GDS 49 -> 58 [49, 54, 46, 28, 45, 24, 23, 13, 6, 7, 2, 1, 8, 9, 18, 19, 20, 57, 21, 31, 38, 39, 40, 58] 58 -> 49 [58, 40, 39, 38, 31, 21, 57, 20, 19, 22, 10, 8, 3, 4, 5, 24, 45, 25, 26, 27, 46, 54, 49] ![](simulation.png) ## Réseau d'amis ### Charger les données ```cypher LOAD CSV WITH HEADERS FROM 'file:///individus.csv' AS row MERGE (i:Individu { id: toInteger(row.id) }) SET i.prenom = row.prenom, i.age = toInteger(row.age), i.sexe = row.sexe, i.etudes = toInteger(row.etudes), i.richesse = toInteger(row.richesse), i.lecture = toFloat(row.lecture), i.musique = toFloat(row.musique), i.sport = toFloat(row.sport); ``` ```cypher CREATE CONSTRAINT individu_id IF NOT EXISTS FOR (i:Individu) REQUIRE i.id IS UNIQUE; ``` ```cypher LOAD CSV WITH HEADERS FROM 'file:///edges.csv' AS row MATCH (a:Individu {id: toInteger(row.source)}) MATCH (b:Individu {id: toInteger(row.target)}) MERGE (a)-[r:AMI]->(b) MERGE (b)-[r2:AMI]->(a); ``` ### Questions 1. Combien d'amis a l'id 58 ? Indice : 3 2. Quels sont les amis de l'id 58 ? Indice : id | prenom ---|--- 27 | Stéphanie 65 | Alain 97 | Stéphanie ![](ami-1.png) 3. Quels sont les amis des amis de l'id 58 ![](amis-2.png) 4. Quelle est la chaine de relation entre l'id 58 et 40 ? Indice : Il n'y en a pas, mais en êtes vous sûr ? 5. Quels sont les personnes qui ont un niveau d'études à 3 et un niveau de richesse à 0 id | prenom ---|--- 35 |Lola 121|Jean 131|André 136|Charlotte