Check if edge is included in SOME MST in linear time (non-distinct values)

后端 未结 4 530
醉梦人生
醉梦人生 2021-01-31 19:24

I am working on an algorithm to check if a given edge is included in one of all possible mst\'s.

For this question, we are considering non-distinct values and our edge e

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 20:09

    I will write down my thoughts about this problem.
    The cycle property is very important in here: The largest edge in any cycle can't be in a minimum spanning tree.
    To prove the cycle property, suppose that there is a minimum spanning tree T that contains the edge e which is the largest cost edge in a cycle. Then we can delete the edge e in tree T and we get two sets S and T. Then the cycle must contain some edge other than e that connects the sets S and T. Then from the cut property, the edge e can't be in a minimum spanning tree.

    Once we have the cycle property, then we go on to make a claim about whether some edge e is in a minimum spanning tree:
    The edge e(v,w) doesn't belong to any minimum spanning tree if and only if there is a path from v and w where every edge on this path is smaller than e.

    Using the above claim, the algorithm goes as follows:
    Delete all the edges larger than e, now we have the graph G'. Run DFS to check if v and w are connected in G'. If v and w are still connected, then edge e doesn't belong to any minimum spanning tree. If v and w are not connected, then edge e is in some minimum spanning tree.

提交回复
热议问题