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?
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
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd
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.
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
Thanks i got the answer ..