Update strongly connected components as edges are added - algorithm

Let G = (V, E) be a strongly connected directed graph. Start with the graph G' = (V, {}). We are given a list L of edges in E such that every edge in L we add to G' (in order) connects two strongly connected components. What's a fast algorithm to keep track of the strongly connected components of G' as we add one edge at a time? Using Kosaraju's or Tarjan's algorithm at every step takes O(|E|(|V|+|E|)) time, which I'm guessing can be improved.

Related

Finding if a graph is still strongly connected after edge removal

A strongly connected digraph is a directed graph in which for each two vertices 𝑒 and 𝑣,
there is a directed path from 𝑒 to 𝑣 and a direct path from 𝑣 to 𝑒. Let 𝐺 = (𝑉, 𝐸) be a
strongly connected digraph, and let 𝑒 = (𝑒, 𝑣) ∈ 𝐸 be an edge in the graph.
Design an efficient algorithm which decides whether 𝐺
β€² = (𝑉, 𝐸 βˆ– {𝑒}), the graph
without the edge 𝑒 is strongly connected. Explain its correctness and analyze its running
time.
So what I did is run BFS and sum the labels, once on the original graph from 𝑒 and then again in G' without the edge (again from 𝑒)
and then : if second sum (in G') < original sum (in G) then the graph isn't strongly connected.
P.S this is a question from my exam which I only got 3/13 points and I'm wondering if i should appeal..
As Sneftel points out, the distance labels can only increase. If u no longer has a path to v, then I guess v's label will be infinite, so the sum of labels will change from finite to infinite. Yet the sum can increase without the graph losing strong connectivity, e.g.,
u<----->v
\ /|
\| /
w
where v's label increases from 1 to 2 because of the indirect path through w.
Since the graph G is strongly connected, G' is strongly connected if and only if there is a path from u to v (this path would replace the edge e).
You can use any path finding algorithm to solve this problem.

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.

MST theorem proof

Let G = (V , E) be a weighted undirected connected graph that contains a cycle, and let e be the maximum-weight edge among all edges in the cycle. I need to prove that there exists a minimum spanning tree of G which does NOT include e.
The idea is intuitively clear and I can show it on a cycle, consisting of 3 nodes. But I do not know how to show that formally for any cycle.
Assume that exists MST with e. Removing e from it, splits tree in two parts. Expecially, it splits cycle nodes into two non empty parts, call them A and B. Since these nodes form a cycle there is at least one more edge between A and B nodes, call it f. Than MST-e+f is a spanning tree with weight less than MST. That means it is not possible to have MST with e.

Shortest Paths in undirected cyclic graphs

Can someone please explain how given an undirected graph G = (V; E); edge lengths le > 0; and edge edges in E.
We can generate the length of the shortest cycle containing edge e.
I understand how to do this in directed graphs, but im not sure how to approach the problem with an undirected graph.
Without modifying the graph: Let e be an edge (u, v). Choose one of the two nodesβ€”I'll choose uβ€”and run an ordinary Dijkstra/BFS starting from u with one minor modification: When making the first hop, you must not add v to the queue. Now search for v.

Finding a minimum-bottle neck spanning tree

Hi so i'm doing some test prep and i need to figure out parts b and c. I know part a is true and i can prove it, but finding the algorithms for part b and c is currently eluding me.
Solve the following for a minimum bottleneck tree where the edge with the maximum cost is referred to as the bottleneck.
(a) Is every minimum-bottleneck
spanning tree of G a minimum-spanning tree of G? Prove your claim.
(b) For a given cost c, give an O(n+m)-time algorithm to
find if the bottleneck cost of a minimum-bottleneck spanning tree
of G is not more than c.
(c) Find an algorithm to find a minimum-bottleneck
spanning tree of G.
thanks in advance to anyone who can help me out
For (b):
Erase every edge in G that costs more than c, then check if the left graph is still connected.
For (c):
Do a binary search on c, using the algorithm that solved (b) as the dividing condition.
Proof of (b):
Let's say the graph we got after deleting edges cost more than c from G is G' .
Then:
If G' is connected, then there must be a spanning tree T in G'. Since no edge in G' costs more than c, we can tell for sure that no edge in T costs more than c. Therefore T is a spanning tree for G' and also G whose bottle neck is at most c
If G' is not connected, then there's no spanning tree in G' at all. Since we know every edge in G- G' costs more than c, and we know that any spanning tree of G will contains at least one edge of G- G', therefore we know there's no edge spanning tree of G whose bottle neck <= c
And of course detecting if a graph is connected costs O(n+m)
Proof of (c):
Say, the algorithm we used in (b) is F(G,c) .
Then we have
If F(G,c) = True for some c, then F(G,c') = True for all c' that have c'>=c
If F(G,c) = False for some c, then F(G,c') = False for all c' that have c'<=c
So we can binary search on c :)
Ans. a)False,every minimum bottleneck spanning tree of graph G is not a minimum spanning tree of G.
b)To check whether the value of minimum bottleneck spanning tree is atmost c,you can apply depth first search by selecting any vertex from the set of vertices in graph G.
***Algorithm:***
check_atmostvalue(Graph G,int c)
{
for each vertex v belongs to V[G] do {
visited[v]=false;
}
DFS(v,c); //v is any randomly choosen vertex in Graph G
for each vertex v belongs to V[G] do {
if(visited[v]==false) then
return false;
}
return true;
}
DFS(v,c)
{
visited[v]=true;
for each w adjacent to v do {
if(visited[w]=false and weight(v,w)<=c) then
DFS(w,c);
}
visited[w]=true;
}
This algorithm works in O(V+E) in the worst case as running timr for depth first search DFS is O(V+E).
This problem can be solved by simply finding the MST of the graph. This based on the following claim:
MST is a MBST for a connected graph.
For a MST, choose the maximum edge e in the MST and the edge e divides the MST into two sets S and T. Then from the cut property, edge e must be the minimum weight among those edges that connects S and T.
Then for a MBST, there must be some edge e' that connect S and T. Then w(e') must be no less than w(e). Thus we know that MST must be a MBST.
However, there is another way to determine the minimum bottleneck. We don't need to computer the MBST. In your question, you actually implies the monotocity of the minimum bottleneck. Therefor we can use binary search combined with the connectivity algorithm to find the minimum bottle neck. I haves seen the use of monocity in other cases. I am a bit amazed that the similar technique can be used here!

Resources