Algorithm for Finding Redundant Edges in a Graph or Tree

前端 未结 6 794
忘掉有多难
忘掉有多难 2020-12-24 08:35

Is there an established algorithm for finding redundant edges in a graph?

For example, I\'d like to find that a->d and a->e are redundant, and then get rid of them,

6条回答
  •  鱼传尺愫
    2020-12-24 09:08

    A sub-graph of a given graph which contains no "redundant edges" is called a 'spanning tree' of that graph. For any given graph, multiple spanning trees are possible.

    So, in order to get rid of redundant edges, all you need to do is find any one spanning tree of your graph. You can use any depth-first-search or breadth-first-search algorithm and continue searching till you have visited every vertex in the graph.

提交回复
热议问题