-
Notifications
You must be signed in to change notification settings - Fork 2
/
final_cut.java
107 lines (90 loc) · 4.91 KB
/
final_cut.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
WHERE s.name = 'U Schlump' AND e.name = 'Sartoriusstraße'
and et.arrival_time > st.departure_time
MATCH p = shortestpath((st)-[*]-(et))
WHERE ALL (r IN relationships(p) WHERE type(r) = 'PRECEDES' OR type(r) = 'LOCATED_AT')
RETURN p, s, e
limit 1
----------------Dijkstra-------------
MATCH (s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
where s.name IN [ 'Schlump', 'U Schlump']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
call apoc.algo.dijkstra(st, et, 'PRECEDES', 'weight') YIELD path, weight
return s, e, path, weight
-------------Shortest Path---------------
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
WHERE s.name = 'U Schlump' AND e.name = 'Sartoriusstraße'
and et.arrival_time > st.departure_time
MATCH p = shortestpath((st)-[:PRECEDES*]-(et))
RETURN p,s,e,
reduce(distance=0, r in relationships(p) | distance+ toInt(r.weight)) AS totalDistance
ORDER BY totalDistance ASC
-------------Shortest Path With Weghts---------------
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
WHERE s.name = 'U Schlump' AND e.name = 'Sartoriusstraße'
and et.arrival_time > st.departure_time
MATCH p = shortestpath((st)-[:PRECEDES*]-(et))
RETURN p,s,e,
reduce(distance=0, r in relationships(p) | distance+ toInt(r.weight)) AS totalDistance
ORDER BY totalDistance ASC
------------All Shortestpath----------------
match (s:Stop)--(st:Stoptime), (e:Stop)--(et:Stoptime)
where s.name IN [ 'Schlump', 'U Schlump']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
and st.arrival_time < et.departure_time
match p = allshortestpaths((st)-[r:PRECEDES*]->(et))
return p
-------------All Path------------------------
match (s:Stop)--(st:Stoptime), (e:Stop)--(et:Stoptime)
where s.name IN [ 'Schlump', 'U Schlump']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
match p = ((st)-[r:PRECEDES*]-(et))
return p
------------All Simple Path--------------------
match (s:Stop)--(st:Stoptime), (e:Stop)--(et:Stoptime)
where s.name IN [ 'Schlump', 'U Schlump']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
CALL apoc.algo.allSimplePaths(st, et, 'PRECEDES', 20) yield path as path
RETURN s, st, e, et path
-----------------------In Direct Routes--------------------------------
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
Where s.name = 'Sartoriusstraße'
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
and et.arrival_time > st.departure_time
MATCH p = shortestpath((st)-[*]-(et))
WHERE ALL (r IN relationships(p) WHERE type(r) = 'PRECEDES' OR type(r) = 'LOCATED_AT' or type(r) = 'PART_OF_TRIP')
RETURN p,s,e,
reduce(distance=0, r in relationships(p) | distance + toInt(r.weight)) AS totalDistance
ORDER BY totalDistance ASC
--------------------------------------------
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
where s.name IN [ 'Schlump', 'U Schlump']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
and et.arrival_time > st.departure_time
MATCH p = shortestpath((st)-[*]-(et))
WHERE ALL (r IN relationships(p) WHERE type(r) = 'PRECEDES' OR type(r) = 'LOCATED_AT' or type(r) = 'PART_OF_TRIP')
RETURN p,s,e,
reduce(distance=0, r in relationships(p) | distance + toInt(r.weight)) AS totalDistance
ORDER BY totalDistance ASC
-----------------------Weight Calculation For Indirect Routes--------------------------------
MATCH(s:Stop)--(st:Stoptime),
(e:Stop)--(et:Stoptime)
where s.name IN [ 'Dörpsweg']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
MATCH p = shortestpath((st)-[*]-(et))
WHERE ALL (r IN relationships(p) WHERE type(r) = 'PRECEDES' OR type(r) = 'LOCATED_AT')
RETURN p,s,e,
reduce(distance=0, r in relationships(p) | distance+ toInt(r.weight)) AS totalDistance
ORDER BY totalDistance ASC
match (s:Stop)--(st:Stoptime), (e:Stop)--(et:Stoptime)
where s.name IN [ 'Dörpsweg']
and e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf', 'Hauptbahnhof Nord', 'Hamburg Hbf (Kirchenallee)', 'Hauptbahnhof/ZOB', 'HBF/Mönckebergstraße' ]
CALL apoc.algo.allSimplePaths(st, et, 'PRECEDES|TRANSFER|PART_OF|LOCATED_AT', 100) yield path as path
RETURN path
Dörpsweg