I tried Dijkstra and Douglas-Peucker algorithms