Commuting Engineer problem using dijkstra's algorithm for shortest path