text: I recently wrote an application somewhat similar to this... but i can't find the code right now.. so for now i'll just pass on a link to Dijkstra's Shortest path algorithm... it's not the exact answer to your question but it'll give you some ideas and some sample code.