Minimum edge in a set of edges which connects a graph - algorithm

The following is an example from my graph theory and algorithm course:
Let A be a minimal subset of edges of a weighted undirected graph G (distinct weight), such that if we remove A from G then G becomes disconnected. The lightest edge in A must be in any MST.
Why this is a correct fact? I couldn't understand it.

According to the definition of minimal edge cut:
A minimal edge cut is an edge cut such that if any edge is put back in the graph, the graph will be reconnected.
In the following figure:
The set, A = {a, b, c, d} is a minimal edge cut.
If A is removed from G, the graph becomes disconnected.
Now, the property: "lightest edge in A must be in any MST" can be explained by the Cut Property:
Therefore the statement is true, because,
The lightest edge of the set A = e = min(a, min(b, min(c,d))) will be the part of MST.

Here's how I think of it. It's given that A is a set of edges that when removed disconnects G. We could say that A connects (at least) two subsets of nodes in G, G1 and G2. There can be no edges linking G1 and G2 that don't go through A, because otherwise the connection of G1 and G2 would not depend on A. Also denote m as the minimum edge within A (not necessarily the minimum of G, although it could be!).
So the question is, can you make the minimum path from G1 to G2 through A without taking its minimum edge m? Well think of another subgraph which is all of the nodes which contain an edge within A. So at least one node from G1 and one node from G2 (such that they are connected through A). The MST of this subgraph must include m, because a MST must include the smallest edge weight. And the MST of G must include the MST of A, else we would be getting from G1 to G2 in a suboptimal way.

Related

Acyclic across cuts in a graph

Given we have a graph G = (V,E) and a subset F with only V in it, for each connected component S of F, add the minimum weight edge in the cut (S, V \ S) to F.
Why is it that every time the minimum weight edge is added to F, F remains acyclic?
To create cycle, you have to create edge which connects vertices which are already connected.
If you add edge between vertices that are not connected, you don't create new cycle. You connect two unconnected components. But graph remains acyclic.
To get better understanding how it works, you could represent connected component of graph as single vertex. And then, when your add edge between unconnected components, your just merge vertices.
By the way, this question is not related to weights (and MST algorithm). It's still valid without weights.

spanning tree including maximum weight [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Let G be a weighted undirected graph and e be an edge with maximum weight in G.Suppose there is a minimum weight spanning tree in G containing the edge e.Which of the following statements is always TRUE?
a.There exists a cut in g having all edges of maximum weight
b.There exists a cycle in G having all edges of maximum weight
c.Edge e can not be contained in a cycle
d.All edges in G have the same weight
Is a previous year exam questing .i am having trouble to under stand it can any one explain it to me .
The bottom three are false, and the following simple graph is a counter-example to all three:
1
a --- b
| /
2 | /
| / 2
| /
c
Any minimum-weight spanning tree contains either the edge <a,c> or the edge <b,c>. In either case, it is easy to check that (b), (c), and (d) all fail.
Edit: (a) is true. Here is a proof:
Let e be an edge of M which is of maximum weight in G, and let M be a minimum-weight spanning tree for G containing the edge e. If the edge e cuts the graph G, then (a) is obviously true. So, let G' be obtained from G by removing the edge e, and suppose G' is connected.
Let M' be obtained from M by removing the edge e. Now we know that M' consists of two components, because M is a tree, and removing one edge from a tree disconnects it into two components. Furthermore every vertex of G' belongs to M', and G' is connected, so we can obtain a spanning tree of G' by adding a single edge of G' to M'. I claim that every such edge is of maximum weight in G.
To see why, suppose there is an edge e' in G' which connects the two components of M', but is of sub-maximal weight in G. Then, we could remove the edge e from M (our original spanning tree), add this edge e' to M to obtain a new spanning tree of G, but it would be of total weight less than that of M, contradicting the minimal-weight of M.
So, consider the set of all edges of G' which connect the two components of M'. These edges together with e form an edge-cut-set of G, and all must be of maximal weight in G.
Let's start from the simple ones - d is wrong - take any MST, and reduce one of the weights to some unique new value in some edge (not e) - it's still an MST, but not all edges have the same weight
c is false - if e was heavier that any other edge it would have been true because if it was in a cycle, you could have removed e from the MST (and if required for connectivity - pick any other edge instead and receive a lighter MST). However, e can be in a cycle if the alternative edges are all of the same weight.
b is false - say e is the heaviest, but not in a cycle, just connects the graph to some remote vertice (that isn't connected otherwise).
a - i'm not sure if you meant that the cut is max weight or all the edges of max weight are there (that's not the same thing), please clarify

Transform a simple directed graph to a simple undirected graph

How would I convert a simple directed graph to a simple undirected one?
Is this possible?
Assuming: (from here)
in a simple digraph loops are disallowed. (A loop is an arc that pairs a vertex to itself.)
and: (from here)
a simple [undirected] graph is an undirected graph that has no loops (edges connected at both ends to the same vertex) and no more than one edge between any two different vertices.
I'm assuming the edges are unweighted, otherwise this can't be done without specifying how this needs to be done.
AM = Adjacency matrix
AL = Adjacency list
Remove the direction of all edges.
AM: For each edge A->B, row A, column B would already be set. Also set row B, column A.
AL: For each edge A->B, the edge already appears in A's AL, also add the edge to B's AL.
Go through all edges, removing all edges for which we already found an edge between the two vertices that are the end-points of that edge (so if A-B has already been processed, if we find another A-B (or equivalently B-A), we must remove that edge). This needs to be done since there can be multiple edges between vertices in a simple directed graph, but this can't happen in a simple undirected graph.
AM: Nothing really needs to be done since an AM forces there to only be a single edge between vertices, so we'd just be overwriting the edges.
AL: For each vertex A, for each edge A-B or B-A in its adjacency list, remove all other edges A-B or B-A in the list.
Source and details...
For each directed edge e=(x,y), add new vertices ve1,…,ve5 and replace e with the edges xve1, ve1ve2, ve1ve3, ve3ve4, ve4ve5, ve3y.
To decode, every leaf (degree-1 vertex) whose neighbour has degree 2 must be ve5 for some edge e=(x,y); its neighbour is ve4 and the other neighbour of ve4 is ve3. ve3 has a unique neighbour that has both degree 3 and is adjacent to a leaf: the neighbour is ve1 and its leaf is ve2 (if ve1 has two leaf neighbours, pick one arbitrarily to be ve2). The other neighbour of ve1 is x and the other neighbour of ve3 is y. Restore the directed edge (x,y) and delete the vertices ve1,…,ve5.
G=(V,E) is a directed graph. (a,b) \in E is a directed edge.
G' = (V, E') is an equivalent undirected graph where (a,b) is transformed as (a,b) and (b,a).
Thus, edge directed edge becomes two edge (one in each direction).

Basic Questions about Minimum Spanning Tree

This is not a homework. I am trying to do exercises from a textbook to understand MST (minimum spanning tree).
Suppose I have a cycle C in a weighted undirected graph G. As I understand, the following is correct:
The heaviest edge in C belongs to no MST of G. That is, there is no MST of G, which contains that edge.
The lightest edge in C belongs to some MST of G. That is, there is an MST of G, which contains that edge.
Now I wonder if the followings claims are correct too.
The lightest edge in C belongs to all MST of G. That is, there is no MST of G, which does not contain that edge.
Any edge in C except the heaviest one belongs to some MST. That is, for each edge in C except the heaviest one there is an MST, which contains that edge.
Could you prove the last claim?
Even for the first claim if there are multiple edges which are lightest, all need not be included in the MST.
The first one of your claims is always true. The lightest edge is on the MST for any graph.
The second one is not always true. It is always true if the entire graph is a
cycle and thus every node has 2 edges incident to it. However, in the general case,
an edge (u,v) of weight k is never on MST whenever there is a path between the nodes u and v
connecting them at a total weight less than k.
I don't think your claims are valid. The problem is that you are only considering a cycle in a larger graph.
Consider for example a graph G consisting of 6 nodes in a cycle (with random weights >1). Your claims might hold for that graph but now add 1 node in the center of the graph and connect it with 6 links of cost 1. The MST of your entire graph now will consist of only those 6 edges (which form a star).
If you now look at your claims, you'll see:
The lightest edge in your cycle does not belong to the MST (=star)
None of the edges in the cycle are in the MST

Design an algorithm to detect cycle in graph G

What would the following algorithm look like:
a linear-time algorithm which, given an undirected graph G, and a particular edge e in it, determines whether G has a cycle containing e
I have following Idea:
for each v that belongs to V,
if v is a descendant of e and (e,v) has not been traversed then check following:
if we visited e before v and left v before we left e then
the graph contains cycle
I am not sure if this is your homework so I'll just give a little hint - use the properties of breadth-first search tree (with root in any of the two vertices of the edge e), its subtrees which are determined by neighbors of the root and the edges between those subtrees.
Per comingstorm's hint, an undirected edge is itself a cycle. A<->B back and forth as many times as you like.

Resources