Implemented shortest path algo