shortest path method in parameters