I am trying to calculate all the relationships between 2 nodes:
For me the shortestpath, allshortestpaths and apoc.algo.dijkstra work perfectly. But these don't fetch all relationships between 2 nodes.
This is my query which works very fast:
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']
AND st.arrival_time < et.departure_time
MATCH p = allshortestpaths((st)-[r:PRECEDES*]->(et))
RETURN p
But when I remove the allshortestpaths and see all relationships, it takes forever.
I tried breaking the query into multiple queries as displayed below but it is also taking a lot of time.
MATCH (s:Stop)--(st:Stoptime), (e:Stop)--(et:Stoptime)
MATCH p1 = (st)-[r1*..4]-(st2:Stoptime),
p2 = (st2:Stoptime)-[r2*..4]-(st3:Stoptime),
p3 = (st4:Stoptime)-[r3*..4]-(st5:Stoptime),
p4 = (st5:Stoptime)-[r4*..4]-(et:Stoptime)
WHERE s.name IN [ 'Schlump', 'U Schlump']
AND e.name IN ['Hauptbahnhof Süd', 'HBF/Steintorwall' , 'Hamburg Hbf']
AND all(x1 in nodes(p1) WHERE (x1:Stoptime))
AND all(x2 in nodes(p2) WHERE (x2:Stoptime))
AND all(x3 in nodes(p3) WHERE (x3:Stoptime))
AND all(x4 in nodes(p4) WHERE (x4:Stoptime))
RETURN r1, r2, r3, r4
What should I do? How can I find all relationships between certain nodes?