简体   繁体   中英

Algorithm for path in an undirected graph between 2 points

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?

Without major limitations you can visit the graph as you like. 2 most common are: 在此处输入图片说明

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

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

Find The Shortest Path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM