-
Notifications
You must be signed in to change notification settings - Fork 6
/
queries.txt
43 lines (36 loc) · 1.08 KB
/
queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# The Dungeon
MATCH (d:Dungeon) RETURN d.name
# All the Rooms
MATCH (r:Room) RETURN r.name
# All the Monsters
MATCH (m:Monster) RETURN m.name
# All the Treasure
MATCH (t:Treasure) RETURN t.name, t.gp
# Rooms and Treasures
MATCH (r:Room)-[:CONTAINS]->(t:Treasure)
RETURN r.name, t.name, t.gp
# Find Longest Path
MATCH p = (:Dungeon)-[:HAS_ENTRANCE]->(:Room)-[:LEADS_TO*]->(:Room)-[:HAS_EXIT]->(:Dungeon)
RETURN nodes(p), relationships(p), length(p) as l
ORDER BY l DESC
LIMIT 1
# Shortest Path to the Most Gold
MATCH (max:Treasure)
WITH max(max.gp) AS maxgp
MATCH (r:Room)-[:CONTAINS]->(t:Treasure)
WHERE t.gp = maxgp
WITH id(r) as dest_id
MATCH p = (start:Room)-[:LEADS_TO*]->(stop:Room)
WHERE id(start) = 1 AND id(stop) = dest_id
RETURN nodes(p), length(p) as len
ORDER BY len ASC
LIMIT 1
# Shortest Path to the Most Gold
MATCH (max:Treasure)
WITH max(max.gp) AS maxgp
MATCH (r:Room)-[:CONTAINS]->(t:Treasure)
WHERE t.gp = maxgp
WITH id(r) as dest_id
MATCH (start:Room), (stop:Room)
WHERE id(start) = 1 AND id(stop) = dest_id
RETURN shortestPath((start)-[:LEADS_TO*]->(stop))