Dijkstra Shortest Distance for Sparse graph in Scala