Sign in to follow this  
Buzz1982

distance b/w 2 nodes in undirected graph

Recommended Posts

Hi, Is there any algorithm that finds the distance b/w 2 arbitrarily chosen nodes in an undirected graph. Please point me to such a resource. Thanks Bye

Share this post


Link to post
Share on other sites
Breadth-first search if unweighted.
Dijkstra if weighted with no negative weights.
Bellman-Ford if weighted with negative weights.

All these search the minimum distance between a node and all other nodes, but you can stop them as soon as the distance to the second node is known.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this