Any algorithm to find the shortest path/distance in android?

前端 未结 1 1251
情话喂你
情话喂你 2020-12-30 16:09

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 id

相关标签:
1条回答
  • 2020-12-30 16:30

    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:

    • each road is a edge
    • each suppermarket is a node
    • your position is a node

    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 :

    enter image description here

    hope it helps

    0 讨论(0)
提交回复
热议问题