Algorithm for Finding Redundant Edges in a Graph or Tree

前端 未结 6 795
忘掉有多难
忘掉有多难 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:06

    Several ways to attack this, but first you're going to need to define the problem a little more precisely. First, the graph you have here is acyclic and directed: will this always be true?

    Next, you need to define what you mean by a "redundant edge". In this case, you start with a graph which has two paths a->c: one via b and one direct one. From this I infer that by "redundant" you mean something like this. Let G=< V, E > be a graph, with V the set of vertices and E ⊆ V×V the set of edges. It kinda looks like you're defining all edges from vi to vj shorter than the longest edge as "redundant". So the easiest thing would be to use depth first search, enumerate the paths, and when you find a new one that's longer, save it as the best candidate.

    I can't imagine what you want it for, though. Can you tell?

提交回复
热议问题