Number of edge distinct paths in bipartite graph - algorithm

We have a bipartite graph, where set A have n vertices and set B have n vertices.
Also each vertices in set A have k edges to set B and each vertices in set B have k edges to set A.
There is a special vertex s that has edges to all vertices to set A, and a special vertex t that has edges to all vertices in B.
How can I prove that there are k edge distinct paths from s to t?
The problem that I am facing is that it asks given the graph mentioned above(Minus the vertices s and t), I need to prove that if at each round I remove all edges from A to B in a way that I can’t remove more than 1 edge from same vertices, there is a way to do this removal so that A and B will become disconnected in k rounds.

Also each vertices in set A have k edges to set B and each vertices in
set B have k edges to set A.
=> There exist at least k vertices in A and there exist at least k vertices in B. (I)
Now we use:
There is a special vertex s that has edges to all vertices to set A,
and a special vertex t that has edges to all vertices in B.
(which we'll call (II)) to show there must be at least k edge disjoint path from s to t.
Consider the following removal-process:
Go from s to a vertex v_a in A.
Go from v_a to a vertex v_bin B.
Go from v_b to t.
Remove all the edges along this path (to make sure we are not reusing them later on)
Note: one such removal round corresponds to exactly a path from s to t.
Now: we can repeat this removal-process at least k times. Why?
Because after k-1 rounds, there must remain at least one vertex v_a_last in A because of (I). This vertex can be reached from s because of (II). This vertex v_a_last must have at least one adjacent vertex v_b_last in B which we have not come along yet (v_a_last has k neighbors in B but we have come across at most k-1 of them so far since we have only made k-1 removal-rounds so far). Since we haven't come along v_b_last so far, the edge from v_b_last to t must still be in the graph. Hence in round k we can go from s to v_a_last to v_b_last to t which is the k-th edge-disjoint paths from s to t.

Related

Multigraph reduction in O(m+n) time

Consider a multigraph G, where the following three reductions need to be made:
Vertices with two neighbors are removed from the graph and their neighbors joined to each other via a new edge.
Vertices with one neighbor are removed from the graph.
Duplicate edges are removed from the graph.
This is a homework question that I had on a recent assignment, where I am asked to show that these three reductions can be done in O(m+n) time. Any help to better understand how to go about doing this is greatly appreciated. Thanks!
This reduction isn't unique: consider a graph with two vertices and one edge, v-w, which has two possible reductions. I will explain how to get an arbitrary valid reduction.
You'll first want to remove duplicate edges: this can be done using a set or a hash-table to identify duplicates, in O(n+m) time. I'll assume you're storing the graph as a dictionary from vertices to their adjacency sets.
After this, you'll want to iterate over the vertices, and keep a set (or any container with O(1) membership testing) to store 'to be deleted' vertices. After this first pass over vertices, this will contain any vertices with degree 1 or 2.
Now, while your 'to be deleted' set isn't empty, you'll:
Pop a vertex v from the set.
If v has degree 0, ignore it.
If v has degree 1 and its neighbor is w, delete v from your graph and remove v from w's adjacency set. If w now has degree 1 or 2 and isn't in the 'to be deleted' set, add it to the set.
Otherwise, v has degree 2, and two distinct neighbors u, w.
If u and w are not adjacent: add an edge from u to w, remove v and its edges from your graph.
If u and w are adjacent: remove v and its edges from your graph. If u or w now have degree 1 or 2, add them to the 'to be deleted' set.
This does constant work per vertex and edge, but relies upon a certain graph representation of 'adjacency sets' where edges can be deleted in constant time. Converting to and from this representation, given adjacency lists or a list of edges, can be done in O(m+n) time.

Algorithm for minimum vertex cover in Bipartite graph

I am trying to figure out an algorithm for finding minimum vertex cover of a bipartite graph.
I was thinking about a solution, that reduces the problem to maximum matching in bipartite graph. It's known that it can be found using max flow in networ created from the bip. graph.
Max matching M should determine min. vertex cover C, but I can't cope with choosing the vertices to set C.
Let's say bip. graph has parts X, Y and vertices that are endpoints of max matching edges are in set A, those who are not belong to B.
I would say I should choose one vertex for an edge in M to C.
Specifically the endpoint of edge e in M that is connected to vertex in set B, else if it is connected only to vertices in A it does not matter.
This idea unfortunately doesn't work generally as there can be counterexamples found to my algorithm, since vertices in A can be also connected by other edges than those who are included in M.
Any help would be appriciated.
Kőnig's theorem proof does exactly that - building a minimum vertex cover from a maximum matching in a bipartite graph.
Let's say you have G = (V, E) a bipartite graph, separated between X and Y.
As you said, first you have to find a maximum matching (which can be achieved with Dinic's algorithm for instance). Let's call M this maximum matching.
Then to construct your minimum vertex cover:
Find U the set (possibly empty) of unmatched vertices in X1, ie. not connected to any edge in M
Build Z the set or vertices either in U, or connected to U by alternating paths (paths that alternate between edges of M and edges not in M)
Then K = (X \ Z) U (Y ∩ Z) is your minimum vertex cover
The Wikipedia article has details about how you can prove K is indeed a minimum vertex cover.
1 Or Y, both are symmetrical

Minimal Vertex Cover using Meet-in-the-Middle

I was studying Meet-in-the-Middle algorithm and found the following exercise:
Given a graph of n nodes (n <= 30), find out a set with the smallest number of vertices such that each edge in the graph has at least one node inside the set.
I have no idea how to do that, only hint I got was
complexity O(3^(n/2))
can you explain the idea?
Take out an edge (u1, v1) from the graph, remove all edges that share a vertex with it. Take out another one (u2, v2), ... continue until the rest of the graph has no edges.
You end up with a number of pairs of vertices
(u1, v1), (u2, v2), ..., (uk, vk)
The rest of the vertices are:
w1, w2, ..., wm
Call the first set of vertices paired vertices, and the second set unpaired vertices. Note, 2k + m = n, there are no edges between unpaired vertices in the original graph.
A vertex cover must have either u1, v1, or both in it. There are 3 choices for each pair (uj, vj). Consider all 3^k ways to include the paired vertices to the vertex cover.
For each of those configurations, an unpaired vertex wi is to be included into the cover if and only if at least one of its neighbors is not in the cover (note that each of wi's neighbors are paired vertices so whether they are included is known).
For each of the 3^k selections of paired vertices, include the unpaired vertices according to the above criteria, then verify each edge between paired vertices has an incident vertex from the cover, if so, it is a candidate cover set. Take one of the candidate cover sets of minimum size as output.
Overall complexity of the above algorithm is O(3^(n/2)E) where E is the number of edges in the graph.

Max-weight set of disjoint paths of length k in a graph G

Suppose you have a graph G with vertices V and edges E. The edges are weighted. You are given a number k. Find the set of paths in G where each path has exactly k edges and the sum of the weights of all edges in the set is maximized. Also, these paths must be disjoint (they can't share any vertex) In other words, I am trying to find the max weight set of disjoint paths of length k in G. Also, I can assume G is a rooted tree. I thought reversing Dijkstra's would be a good start but I don't think that actually gets me anywhere. Any advice/help?

Find all edges in min-cut

Let (G,s,t,{c}) be a flow network, and let F be the set of all edges e for which there exists at least one minimum cut (A,B) such that e goes from A to B. Give a polynomial time algorithm that finds all edges in F.
NOTE: So far I know I need to run Ford-Fulkerson so each edges has a flow. Furthermore I know for all edges in F, the flow f(e) = c(e). However not all edges in a graph G which respects that constraint will be in a min-cut. I am stuck here.
Suppose you have computed a max flow on a graph G and you know the flow through every edge in the graph. From the source vertex s, perform a Breadth First Search OR Depth First Search on the original graph and only traverse those edges that have flow less than the capacity of the edge. Denote the set of vertices reachable in this traversal as S, and unreachable vertices as T.
To obtain the minimum cut C, we simply find all edges in the original graph G which begin at some vertex in S and end at some vertex in T.
This tutorial in Topcoder provides an explanation / proof of the above algorithm. Look at the section beginning with the following text:
A cut in a flow network is simply a partition of the vertices in two sets, let's call them A and B, in such a way that the source vertex is in A and the sink is in B.
I shall attempt to provide an explanation of the corresponding section in the Topcoder tutorial (just for me to brush up on this as well).
Now, suppose that we have computed a max flow on a graph G, and that we have computed the set of edges C using the procedure outlined above. From here, we can conclude several facts.
Fact 1: Source vertex s must be in set S, and sink vertex t must be in set T.
Otherwise, vertices s and t must be in the same set, which means that we must have found a path from s to t consisting only of edges that have flow less than capacity. This means that we can push more flow from s to t, and therefore we have found an augmenting path! However, this is a contradiction, since we have already computed a max flow on the graph. Hence, it is impossible for source vertex s and sink vertex t to be connected, and they must be in different sets.
Fact 2: Every edge beginning at set S and ending at set T must have flow == capacity
Again we prove this by contradiction. Suppose that there is a vertex u in S and a vertex v in T, such that edge (u,v) in the residual network has flow less than capacity. By our algorithm above, this edge will be traversed, and vertex v should be in set S. This is a contradiction. Therefore, such an edge must have flow == capacity.
Fact 3: Removing the edges in C from graph G will mean that there is no path from any vertex in set S to any vertex in set T
Suppose that this is not the case, and there is some edge (u,v) that connects vertex u in set S to vertex v in set T. We can separate this into 2 cases:
Flow through edge (u,v) is less than its capacity. But we know this will cause vertex v to be part of set S, so this case is impossible.
Flow through edge (u,v) is equal to its capacity. This is impossible since edge (u,v) will be considered as part of the edge set C.
Hence both cases are impossible, and we see that removing the edges in C from the original graph G will indeed result in a situation where there is no path from S to T.
Fact 4: Every edge in the original graph G that begins at vertex set T but ends at vertex set S must have a flow of 0
The explanation on the Topcoder tutorial may not be obvious on first reading and the following is an educated guess on my part and may be incorrect.
Suppose that there exists some edge (x,y) (where x belongs to vertex set T and y belongs to vertex set S), such that the flow through (x,y) is greater than 0. For convenience, we denote the flow through (x,y) as f. This means that on the residual network, there must exist a backward edge (y,x) with capacity f and flow 0. Since vertex y is part of set S, the backward edge (y,x) has flow 0 with capacity f > 0, our algorithm will traverse the edge (y,x) and place vertex x as part of vertex set S. However, we know that vertex x is part of vertex set T, and hence this is a contradiction. As such, all edges from T to S must have a flow of 0.
With these 4 facts, along with the Max-flow min-cut theorem, we can conclude that:
The max flow must be less than or equal to the capacity of any cut. By Fact 3, C is a cut of the graph, so the max flow must be less than or equal to the capacity of cut C.
Fact 4 allows us to conclude that there is no "back flow" from T to S. This along with Fact 2 means that the flow consists entirely of "forward flow" from S to T. In particular, all the forward flow must result from the cut C. This flow value happens to be the max flow. As such, by the Max-flow min-cut theorem, we know that C must be a minimum cut.

Resources