简体   繁体   中英

How to look for the edges that must exist in every minimum spanning trees of a weighted graph

Given an undirected weighted graph, the actual weights of the edges are not known, however; instead, each edge is classified as either Light, Medium or Heavy.

All Light edges have a smaller weight than any Medium or Heavy edge.

All Medium edges have a smaller weight than any Heavy edge

In general, nothing is known about the relationship between two edges in the same weight class. Then, how to identify all the edges that must exist in every MST of this graph? The following is what I'm thinking: 1. determine the number of strongly connected components. 2. the edges composed of articulation points must exist in the MST. 3. The lightest edge in each connected component must exist in the MST.

I am not sure whether my thinking is correct or not? If it is correct, how to implement the code with java? Thank you very much.

Jason, I will not go into the description of how to implement the code in Java, but let's look at the thought process behind the algorithm for your problem.

Since your vertices are classified into three weight categories, we can re-label them with comparative weights as follows: Light is 1; Medium is 2; Heavy is 3. This way, your conditions are maintained.

Next, we can use Kruskal's Minimum Spanning Tree Algorithm (MST) as we normally would to create a minimum spanning tree on an undirected weighted graph. This algorithm is greedy, so it would sort the edges from light to heavy, pick the next smallest edge so long as it doesn't create a cycle, and then repeat step 2 until all vertices are included in the MST. (See link below for reference) https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/

When it comes to verifying that your algorithm is correct, there are two potential cases.

1). You can reveal the actual weights of edges in the MST and those excluded. Check the excluded edges and if when adding an excluded edge to the MST, that edge is not the heaviest in the cycle, swap it with the heaviest edge. Keep doing this until all originally-excluded edges are explored and the MST maintains its property of containing every vertex. 2). You cannot reveal the actual weights of any vertex in the graph. In this case, there is no way to even verify that your algorithm created a Minimum Spanning Tree, so your algorithm would have no way of checking itself. In any event, using Kruskal's algorithm with comparative weights would create a spanning tree that is very close to minimum, even without knowing the actual weights.

Here is a simple algorithm that runs in O(|E|)- time.

  1. Initialize an empty set S.
  2. Add all bridges in the graph to S.
  3. Remove all heavy edges from the graph.
  4. Add all bridges in the graph to S.
  5. Remove all medium edges from the graph
  6. Add all bridges in the graph to S.
  7. Return S.

There are a few fast algorithms that find all bridges in a graph, such as this one


Why is the algorithm above correct?

Theorem on characterization of an all-MST edge : An edge appears in every minimum spanning tree if and only if for any cycle that contains that edge, that cycle also contains an edge heavier than that edge.

The theorem above is proved here . By the way, an edge that is in every MST of a graph is called a critical MST edge sometimes.


The algorithm given in the question is incorrect. For example, a triangle with all 3 edges classified as light. For another example, a triangle with one light edge, one medium edge and one heavy edge.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM