I've been spending a lot of time reading online presentations and textbooks about the cut property of a minimum spanning tree. I don't really get what it's suppose to illustrate or even why it's practical. Supposedly it helps determine what edges to add to a MST, but I fail to see how it accomplishes that. My understanding of the cut property so far is that you split a MST into two arbitrary subsets. Any help here? Thanks!
A cut of a connected graph is a minimal set of edges whose removal separate the graph into two components (pieces). The minimal cut property says that if one of the edges of the cut has weight smaller than any other edge in the cut then it is in the MST. To see this, assume that there is an MST not containing the edge. If we add the edge to the MST we get a cycle that crosses the cut at least twice, so we can break the cycle by removing the other edge from the MST, thereby making a new tree with smaller weight, thereby contradicting the minimality of the MST.
There's another property up on which this explanation is based.
"For any of the cut, if there are even number of edges crossing the cut then there must be a cycle crossing the cut"
Because MST does not contain any cycle there won't be any even number of edges crossing the cut.
Proof by contradiction:
Assume that there's a MST not containing edge with min weight "e". If we add the edge "e" to the MST we get a cycle crossing the cut at least twice. We can remove other edge with more weight and break the cycle which results in an ST containing lesser weighing edge "e". This is in contradiction with the assumption.
I'd like to share what I understand about Cut Property to help. If there're anything to improve in my post, please comment below so I can modify my answer.
Background:
For simplification, suppose there are 2 separate MSTs (T1 and T2) formed in a graph G(V, E). There are edges not yet connected between T1 and T2.
Goal:
We want to show that when T1 and T2 are connected, a newly produced tree is also an MST - an optimal solution.
>> My Understanding of Cut Property:
Among the edges not yet connected between T1 and T2, pick the lightest edge. Adding it to connect T1 and T2 makes a new MST - an optimal solution.
Note: Connecting an edge in the same tree introduces a cycle. But a tree shouldn't contain a cycle
Related
I'm learning the requirements for finding a minimum spanning tree for a connected, undirected graph with distinct edge costs. One of the requirements is that there must be no cycles created in the tree, and the reason given for why a cycle isn't created by, for example Prim's algorithm, is that "an edge which is the only edge crossing a cut cannot create a cycle" (Lonely cut corollary). However, when I look at a cut, I normally see multiple edges crossing the cut. They do not necessarily connect the same two vertices, but there are multiple edges nevertheless. Shouldn't the lonely cut corollary be worded as "an edge which is the only one crossing a cut and connecting two specific vertices in each set"? Or am I just misunderstanding the corollary?
How is a cut lonely if there are often multiple edges crossing a cut in a connected undirected graph?
It isn't.
And thus the corollary doesn't say anything about it. It only says something about an edge IF you have a lonely cut.
After going back and reviewing the material again, I realized I was conflating edges of the original graph with edges of the graph being selected to create the tree by Prim's algorithm. As long as an edge crossing a cut is the first one added by the algorithm to cross that particular cut, no cycles are being created and Prim outputs a tree.
I'm taking the Algorithms: Design and Analysis II course, and one of the questions is as follows:
Consider a connected undirected graph with distinct edge costs. Which
of the following are true? [Check all that apply.]
Suppose the edge 𝑒 is not the cheapest edge that crosses the cut (𝐴,𝐵). Then 𝑒 does not belong to any minimum spanning tree.
Suppose the edge 𝑒 is the most expensive edge contained in the cycle 𝐶. Then 𝑒 does not belong to any minimum spanning tree.
The minimum spanning tree is unique.
Suppose the edge 𝑒 is the cheapest edge that crosses the cut (𝐴,𝐵). Then 𝑒 belongs to every minimum spanning tree.
To my knowledge, all four options are correct. Options 1, 2 and 4 follow from the Cut property; option 3 is correct because edge weights are distinct. However, including option 1 is turning out to be wrong. Why?
No
Yes
Yes
Yes
The main part here is to answer #3. For a graph with all distinct edge costs that is true. Answers for all other questions you can derive using answer to the third one.
For #1:
A1 --- B1
|
A2 --- B2
Suppose w(A1,B1) > w(A2,B2), but you still need to include both of them into MST.
First of all lets look at the mst definition.MST is a subset of a connected undirected graph with distinct edge costs that connects all the vertices together, without any cycles and with the minimum possible total edge weight.
1.If the edge e is the only way to traverse A to B without causing a cycle it may belong to a mst.
2.If there is a cycle C then we can't talk about mst it will be a closed path.That is the definition of the cycle.
3.If each edge has a distinct cost as you mentioned then there will be only one, unique minimum spanning tree.
4.It may not because it can cause a loop like cycle or circuit then we don't use that edge to traverse A to B
I have this question from Robert Sedgewick's book on algorithms.
Critical edges. An MST edge whose deletion from the graph would cause the
MST weight to increase is called a critical edge. Show how to find all critical edges in a
graph in time proportional to E log E. Note: This question assumes that edge weights
are not necessarily distinct (otherwise all edges in the MST are critical).
Please suggest an algorithm that solves this problem.
One approach I can think of does the job in time E.V.
My approach is to run the kruskal's algorithm.
But whenever we encounter an edge whose insertion in the MST creates a cycle and if that
cycle already contains an edge with the same edge weight, then, the edge already inserted will not be a critical edge (otherwise all other MST edges are critical edges).
Is this algorithm correct? How can I extend this algorithm to do the job in time E log E.
The condition you suggest for when an edge is critical is correct I think. But it's not necessary to actually find a cycle and test each of its edges.
The Kruskal algorithm adds edges in increasing weight order, so the sequence of edge additions can be broken into blocks of equal-weight edge additions. Within each equal-weight block, if there is more than one edge that joins the same two components, then all of these edges are non-critical, because any one of the other edges could be chosen instead. (I say they are all non-critical because we are not actually given a specific MST as part of the input -- if we were then this would identify a particular edge to call non-critical. The edge that Kruskal actually chooses is just an artefact of initial edge ordering or how sorting was implemented.)
But this is not quite sufficient: it might be that after adding all edges of weight 4 or less to the MST, we find that there are 3 weight-5 edges, connecting component pairs (1, 2), (2, 3) and (1, 3). Although no component pair is joined by more than 1 of these 3 edges, we only need (any) 2 of them -- using all 3 would create a cycle.
For each equal-weight block, having weight say w, what we actually need to do is (conceptually) create a new graph in which each component of the MST so far (i.e. using edges having weight < w) is a vertex, and there is an edge between 2 vertices whenever there is a weight-w edge between these components. (This may result in multi-edges.) We then run DFS on each component of this graph to find any cycles, and mark every edge belonging to such a cycle as non-critical. DFS takes O(nEdges) time, so the sum of the DFS times for each block (whose sizes sum to E) will be O(E).
Note that Kruskal's algorithm takes time O(Elog E), not O(E) as you seem to imply -- although people like Bernard Chazelle have gotten close to linear-time MST construction, TTBOMK no one has got there yet! :)
Yes, your algorithm is correct. We can prove that by comparing the execution of Kruskal's algorithm to a similar execution where the cost of some MST edge e is changed to infinity. Until the first execution considers e, both executions are identical. After e, the first execution has one fewer connected component than the second. This condition persists until an edge e' is considered that, in the second execution, joins the components that e would have. Since edge e is the only difference between the forests constructed so far, it must belong to the cycle created by e'. After e', the executions make identical decisions, and the difference in the forests is that the first execution has e, and the second, e'.
One way to implement this algorithm is using a dynamic tree, a data structure that represents a labelled forest. One configuration of this ADT supports the following methods in logarithmic time.
MakeVertex() - constructs and returns a fresh vertex.
Link(u, c, v) - vertices u and v must not be connected. Creates an unmarked edge from vertex u to vertex v with cost c.
Mark(u, v) - vertices u and v must be endpoints of an edge e. Marks e.
Connected(u, v) - indicates whether vertices u and v are connected.
FindMax(u, v) - vertices u and v must be connected. Returns the endpoints of an unmarked edge on the unique path from u to v with maximum cost, together with that cost. The endpoints of this edge are given in the order that they appear on the path.
I make no claim that this is a good algorithm in practice. Dynamic trees, like Swiss Army knives, are versatile but complicated and often not the best tool for the job. I encourage you to think about how to take advantage of the fact that we can wait until all of the edges are processed to figure out what the critical edges are.
Given a subset of edges of a graph G = (V,E), how can we check whether it is a valid cut-set of the graph or not?
Note: A cut is a partition of the vertices of a graph into two disjoint subsets. So, cut-set of the cut is the set of edges whose end points are in different subsets of the partition.
I am interested to find an algorithm for this problem
A simple algorithm would be to remove the suspected cut-edges from the graph, and see if you can still get from a node of a removed edge to its counterpart. If you still can, it was not a full cut. So if you remove E2 which had nodes A and D, you can use breadth first search from A and see if you ever get to D. It should be linear in space requirements and complexity since we store all the nodes we've visited so we don't backtrack and visit any node twice.
This wiki page has some nice pictures that might help: http://en.wikipedia.org/wiki/Cut_%28graph_theory%29
It's a valid cut set if, with that edge subset removed, it's no longer a connected graph.
If you're asking for algorithms, you should be able to start at any node and see if you can reach all other nodes via depth first search. If so, it's not a valid cut set, if it can't, it's a valid cut set.
If we have an (arbitrary) connected undirected graph G, whose edges have distinct weights,
does every MST of G contains the minimum weighted edge?
is there an MST of G that does not contain the maximum weighted edge?
Also, I'm more thankful if someone can give a hint of the key things one must keep in mind when dealing with such MST questions.
This is a homework problem. Thanks.
is there an MST of G that does not contain the maximum weighted edge?
There may be, but there doesn't have to be. Consider a 4-vertex graph as follows:
[A]--{2}--[B]
| |
| |
{1} {3}
| |
| |
[C]-{50}--[D]
The minimum spanning tree consists of the edge set {CA, AB, BD}. The maximum edge weight is 50, along {CD}, but it's not part of the MST. But if G were already equal to its own MST, then obviously it would contain its own maximum edge.
does every MST of G contains the minimum weighted edge?
Yes. MSTs have a cut property. A cut is simply a partition of the vertices of the graph into two disjoint sets. For any cut you can make, if the weight of an edge in that cut is smaller than the weights of the other edges in the cut, then this edge belongs to all MSTs in the graph. Because you guaranteed that the edge weights are distinct, you have also guaranteed that there is an edge which is smaller than all other edges.
Also, I'm more thankful if someone can give a hint of the key things one must keep in mind when dealing with such MST questions.
Your best bet is to reason about things using the properties of MSTs in general, and to try to construct specific counterexamples which you think will prove your case. I gave an instance of each line of reasoning above. Because of the cut and cycle properties, you can always determine exactly which edges are in an MST, so you can systematically test each edge to determine whether or not it's in the MST.
Does every MST of G contains the minimum weighted edge?
Yes. Lets assume we have a MST which does not contain the min weight edge. Now the inclusion of this edge to the MST will result in a cycle. Now there will always be another edge in the cycle which can be removed to remove the cycle and still maintain the graph(MST) connected.
Is there an MST of G that does not contain the maximum weighted edge?
Depends on the graph. If the graph itself is a tree then we need to include all of its n-1 edges in the MST, so the max weight edge cannot be excluded. Also if the max weight edge is a cut-edge so that its exclusion will never result in connectivity, then the max weight edge cannot be excluded. But if the max weight edge is a part of a cycle then it is possible to exclude from the MST.
For your first question the answer is no, and kruskal's algorithm proves it. It will always select the minimum cost edge.
For the second question the answer is yes, and it's trivial to find an example graph:
1 - 2 (cost 10)
2 - 3 (cost 100)
3 - 1 (cost 1000)
The third edge will never be selected as it introduces a cycle. So basically, if the edge with the maximum cost would create a cycle if inserted in the MST, it won't be inserted.
I see you too are studying for CSC263 through the 2009 test? (Same here!)
Another way to see that the minimum is always in the MST is to look simply at this minimum edge (call it e):
e
v1 ---------------- v2
(Assume this has connections to other verticies). Now, for e NOT to be included in the final MST means at one point we have, without loss of generality, v1 in the MST but not v2. However, the only way to add v2 without adding e would be to say that the addition of v1 didn't add e to the queue (because by definition, e would be at the top of the queue because it has lowest priority) but this contradicts the MST construction theorem.
So essentially, it is impossible to have an edge with minimum weight not get to the queue which means that any MST constructed would have it.