How to find the shortest paths in undirected graphs? i am confused as the algorithms I have found is for directed graphs....Can anyone please help?
Printable View
How to find the shortest paths in undirected graphs? i am confused as the algorithms I have found is for directed graphs....Can anyone please help?
You can try Dijkstra's Algorithm, which uses weighted edges. If your graph doesn't have weighted edges, just set the weight for each one to 1.
QuantumPete
You can imagine an undirected graph to be a directed graph having same values in a[i][j] and a[j][i] where a is your adjacency matrix. Then run your favorite algorithm and you will get the answer.
Thanks i got the answer .. :)