Implementation of Dijkstra's algorithm in C#