added linear time dijkstra algorithm