It's essentially a question of graph traversal control.
My issue isn't really about roadtrip but I'll use a metaphor to make it easier to explain and captures the essence of the issue.
I have a "undirected weighted disconnected cyclic" graph containing about 1M nodes, which we can call "City", and 1M relations, which we can call "ROADS", roads have a weight property "distance".
I'm trying to make a query, that will, given a starting City node and a maximum distance traveled called Fuel tank:
- Go to the unvisited city closest to any of our visited cities (we get "free teleport" at this step to all our visited cities)
- Deduct the Distance from Fuel tank.
- While Fuel Tank > 0 ==> Go to step 1
- Return the ids of the visited City nodes (and optionally some extra info about the path).
I'm not sure if this is possible without going into the Java back-end, or having a script loop that generate the next Cypher query at each step given previous results.
All help appreciated, thanks.
Optional clarification P.S:
Example of step 1
Given we already traveled to City A, B and C.
For the next City, we look for the closest city to ANY of our A,B,C.
Let's say closest city is D and is closest to B. We would go to D and pay the "distance" between B and D.
At the next round we would do the same with Cities A,B,C and D.