Hi, I am working on a project dealing with bus routes and I’m using neo4j 
to retrive indirect routes between two stops. I modelled it in a way in 
which I was creating a ‘Route’ relationship for all the routes between two 
stops. This was okay at first but then I reached a point where I had 
at-least 10 relationships between any two given nodes and that led to most 
of the queries getting timed out.

So to reduce the number of relationships between two nodes, I am 
maintaining the routes between two stops as an array relationship property. 
 

My question is how can I query the DB in such a way that I get that route 
which requires the lest number of bus changes. Can I implement something 
like backtracking to achieve this?

I have set up a neo4j instance with some dummy data. Here’s the link to it 
- http://207.154.231.108:7474/browser/ 

The query I’m using to find the shortest distance between two nodes.





MATCH (origin:Stop {name: "Petraro"}), (destination:Stop {name: "Rossano 
Scalo - Torre Pisani"}),
path = allShortestPaths((origin)-[:Route*]->(destination))
RETURN path

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to