Find all chordless cycles in an undirected graph

前端 未结 5 1367
有刺的猬
有刺的猬 2020-12-04 15:47

How to find all chordless cycles in an undirected graph?

For example, given the graph

0 --- 1
|     | \\
|     |  \\
4 --- 3 - 2

th

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 16:28

    How about this. First, reduce the problem to finding all chordless cycles that pass through a given vertex A. Once you've found all of those, you can remove A from the graph, and repeat with another point until there's nothing left.

    And how to find all the chordless cycles that pass through vertex A? Reduce this to finding all chordless paths from B to A, given a list of permitted vertices, and search either breadth-first or depth-first. Note that when iterating over the vertices reachable (in one step) from B, when you choose one of them you must remove all of the others from the list of permitted vertices (take special care when B=A, so as not to eliminate three-edge paths).

提交回复
热议问题