I am new to android and I am doing some project planning.
To finish the planning, I have to know which algorithms or techniques that I will use in my project. The idea is very simple. I just want to determine the shortest path/distance that between my current location and few supermarkets location.
Are there any algorithms or Android API I can apply?
Dijkstra's Algorithm finds the shortest path between a given node (which is called the "source node") and all other nodes in a graph.
Dijkstra's algorithm finds the shortest path between a node and every other node in the graph.
Dijkstra's Shortest Path Dijkstra's algorithm is used for our fastest path algorithm because it can find the shortest path between vertices in the graph. The coordinates on the arena are considered as the vertices in the graph.
I don't know about Android API, but if there is something you should be able to find it on google. For example try to look at "google map api", and if you can get directions and distances with the api easily.
Look for exemple at the Google direction API
Or even better : google distance matrix api it gives you the distance of any given set of points.(for example a matrix with at each row : [your position, one supermarket)
for example : if I am 20 passage de la bonne graine in paris and I want to check how far is the monoprix (supermarket 5 Rue Godefroy Cavaignac) I can request something like that : http://maps.googleapis.com/maps/api/distancematrix/json?origins=20%20passage%20de%20la%20bonne%20graine&destinations=45%20Rue%20Godefroy%20Cavaignac,%2075011%20Paris,%20France&mode=walking&language=fr-FR&sensor=false
In term of algorithm you can process as below:
create a graph:
then apply Dijktra's algorithm to find the shortest path between your position and all supermarkets
Here is a nice illustration (from wikipedia) on how Dijktra's algorithm works :
hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With