Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --To create the graph
- CREATE (d:CITY {name:"Delhi", population:43000000}),
- (m:CITY {name:"Mumbai", population:17000000}),
- (k:CITY {name:"Kolkata", population:14000000}),
- (b:CITY {name:"Bengaluru", population:11000000}),
- (g:TOWN {name:"Ghaziabad", population:2000000}),
- (r:TOWN {name:"Rishikesh", population:140000}),
- (d)-[:WAY_TO {distance:1400}]->(m),
- (d)-[:WAY_TO {distance:1500}]->(k),
- (d)-[:WAY_TO {distance:2100}]->(b),
- (d)-[:WAY_TO {distance:40}]->(g),
- (d)-[:WAY_TO {distance:230}]->(r),
- (m)-[:WAY_TO {distance:1900}]->(k),
- (m)-[:WAY_TO {distance:1000}]->(b),
- (m)-[:WAY_TO {distance:1460}]->(g),
- (m)-[:WAY_TO {distance:1700}]->(r),
- (k)-[:WAY_TO {distance:1800}]->(b),
- (k)-[:WAY_TO {distance:1500}]->(g),
- (k)-[:WAY_TO {distance:1700}]->(r),
- (b)-[:WAY_TO {distance:2150}]->(g),
- (b)-[:WAY_TO {distance:2300}]->(r),
- (g)-[:WAY_TO {distance:211}]->(r)
- --To obtain all nodes and relationships
- MATCH (n)
- OPTIONAL MATCH (n)-[r]->(m)
- RETURN n, r, m
- --To obtain way from Delhi to Mumbai
- MATCH (d:CITY {name:"Delhi"})-[r:WAY_TO]-(m:CITY {name:"Mumbai})
- --To obtain way from Delhi to Mumbai through an intermediary city
- MATCH (d:CITY {name:"Delhi"})-[r1:WAY_TO]-(x)-[r2:WAY_TO]-(m:CITY {name:"Mumbai"})
- RETURN d, r1, r2, x, m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement