The real question is how to represent a graph data structure in ruby (some example code might help me understand).
I currently have an idea to represent a graph. that is every Node
has an array
of neighbourNodes
which are object_id
of node objects. Is there any better solution? Can i achieve this with some library easily. I have looked at GRATR
and RGL
. both are outdated (atleast i think so.) Anyway any working example on tuby 2.0.0 will help me a lot.
I have Busstops
which compose Routes
. Routes
is a sequence of Busstops
. How would I represent the graph for all the Routes
. I want to use Dijkstra's Algorith to find a shortest path between two busstops (which may or may not lie on the same Route
. Which means you have to change a bus on the way)).
As mentioned in the comments, since you do not want to use a new data store such as Neo4j, the best option is using PostGIS and pgRouting. They are relatively easy to implement as they use SQL and are extensions for PostgreSQL.