Here's an implementation of Dijkstra's algorithm in C#:
main.cs1736 chars73 lines
Note that in this implementation, the graph is represented as a 2D array, where graph[i,j]
represents the weight of the edge between node i
and node j
. In this example, 0
represents no edge between nodes.
Also, the main function simply creates a sample graph and runs the algorithm on it. In practice, you would likely want to read the graph data from a file or other source.
gistlibby LogSnag