Advertisement
capnspek

Untitled

Mar 10th, 2023
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. --To create the graph
  2. CREATE (d:CITY {name:"Delhi", population:43000000}),
  3. (m:CITY {name:"Mumbai", population:17000000}),
  4. (k:CITY {name:"Kolkata", population:14000000}),
  5. (b:CITY {name:"Bengaluru", population:11000000}),
  6. (g:TOWN {name:"Ghaziabad", population:2000000}),
  7. (r:TOWN {name:"Rishikesh", population:140000}),
  8. (d)-[:WAY_TO {distance:1400}]->(m),
  9. (d)-[:WAY_TO {distance:1500}]->(k),
  10. (d)-[:WAY_TO {distance:2100}]->(b),
  11. (d)-[:WAY_TO {distance:40}]->(g),
  12. (d)-[:WAY_TO {distance:230}]->(r),
  13. (m)-[:WAY_TO {distance:1900}]->(k),
  14. (m)-[:WAY_TO {distance:1000}]->(b),
  15. (m)-[:WAY_TO {distance:1460}]->(g),
  16. (m)-[:WAY_TO {distance:1700}]->(r),
  17. (k)-[:WAY_TO {distance:1800}]->(b),
  18. (k)-[:WAY_TO {distance:1500}]->(g),
  19. (k)-[:WAY_TO {distance:1700}]->(r),
  20. (b)-[:WAY_TO {distance:2150}]->(g),
  21. (b)-[:WAY_TO {distance:2300}]->(r),
  22. (g)-[:WAY_TO {distance:211}]->(r)
  23.  
  24. --To obtain all nodes and relationships
  25. MATCH (n)
  26. OPTIONAL MATCH (n)-[r]->(m)
  27. RETURN n, r, m
  28.  
  29. --To obtain way from Delhi to Mumbai
  30. MATCH (d:CITY {name:"Delhi"})-[r:WAY_TO]-(m:CITY {name:"Mumbai})
  31.  
  32. --To obtain way from Delhi to Mumbai through an intermediary city
  33. MATCH (d:CITY {name:"Delhi"})-[r1:WAY_TO]-(x)-[r2:WAY_TO]-(m:CITY {name:"Mumbai"})
  34. RETURN d, r1, r2, x, m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement