class Graph modified with Dijkstra algorithm