Algorithm for path in an undirected graph between 2 points

1.1k views Asked by At

Suppose we have an undirected graph, and two nodes A and B. I need to write a method to find a path without cycles between A and B. All edges of this graph have the same weight. The method must terminate as soon as it finds such a path. How can I implement this?

2

There are 2 answers

3
Margus On

Without major limitations you can visit the graph as you like. 2 most common are: enter image description here

For more help i advice you try someting and show some effort on your part.

4
hdoghmen On

You can find here an implementation of Dijkstra's algorithm Algorithm to :

Find The Shortest Path