Dijkstra algorithm on iOS

I track locations and their connections to other locations.
I save places in NSArray, while each place is represented as a dictionary. Each place has a dictionary with attributes (locationName, Connections, latitude, longitude), where Connections is an array of other places where TO (not from) is connected to this place. I use lat / lon and the Haversine algorithm to determine the distance between two points.

NEXT, I would like to use dijkstra's shortest path algorithm to find the shortest path between source and destination (source and destination are user selectable)

It is not for commercial use and does not need the support of hundreds or thousands of places.

I am looking for some objective C code that will perform this search.

+7
source share
3 answers

A quick google found objective-c code in snyderp / PESGraph which says

PESGraph is a simple graphics implementation for Foundation.kit that allows you to smooth out the structure of nodes and paths, and then find the shortest path between them. It includes unit tests, which also give some examples of how to use the code.

Also this question was previously asked on SO theres-an-easy-way-to-apply-a-shortest-path-alghoritm-in-objective-c , and the solution pointed to the same git repository that I found through Google.

+4
source

I had to write my own sample code because I could not find a good and working example. You can check it out here:

https://github.com/aolszak/AOShortestPath

+1
source

Shameless plugin: mj-dijkstra The graph view is an NSDictionary or an object that behaves like a dictionary.

0
source

All Articles