Lingo algorithm achieves the shortest path