Find the loop in the undirected graph (boost) and return its vertices and edges

I need functions that find a loop in an undirected graph (boost) and return its vertices and edges. He only needs to return the vertices / edges of one cycle in the graph. My question is: what is the best way to do this with boost? I do not experience this.

+3
source share
3 answers

If you want to find the cycle a , then the depth search should be perfect first. The DFS visitor has a back_edge function. When it is called, you have an edge in the loop. Then you can view the map of the predecessor to restore the cycle. Note:

  • strong_components, , ,
  • , , , , Boost.Graph
+1

Boost, S.O. :

: BFS. node "" "" ( , ). , A B ( B ), : 1) A , / . 2) B , / . 3) A, B, AB 4) "", . LIFO () 1) FIFO 2)

, .

+3

You can usually do this with a depth search. I am not familiar with the advanced GUI features, but this page will give you an overview of the algorithm.

+2
source

Source: https://habr.com/ru/post/1725958/


All Articles