Prepared matrix for weighted graph
Dijkstra algorithm