dijkstras algorithm function finished