Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matching in bipartite graphs Given: non-weighted bipartite graph not covered node extending alternating path initial matching Algorithm: so-called “extending.

Similar presentations


Presentation on theme: "Matching in bipartite graphs Given: non-weighted bipartite graph not covered node extending alternating path initial matching Algorithm: so-called “extending."— Presentation transcript:

1 Matching in bipartite graphs Given: non-weighted bipartite graph not covered node extending alternating path initial matching Algorithm: so-called “extending alternating path”, we start with a not covered node; next step: node from the matching (maybe several edges) in this case: no extending alternating path; result: perfect matching

2 Vertex Cover Problem In general graphs is NP-hard (best approximation known - 2-approximation) In bipartite graphs  exact algorithm (we can for sure find optimal matching with maximum # of edges) 12 3 minimum cardinality matching M OPT = minimum vertex cover |OPT|  |M| Proof: we need at least 1 vertex in OPT per edge in M

3 Vertex Cover Problem In bipartite graphs |Maximum matching| = |Minimum vertex cover| Algorithm (also the proof): Pick a node that covers red and blue edge (red=from M, blue=not from M) (except - last case) - such blue edge that has one endpoint not covered by the matching. If such blue edge does not exist, we have perfect matching (from that point on, all nodes are covered by the matching). Every time we have isolated node, we “drop” it

4 Vertex Cover Problem In case of perfect matching  take one part of the bipartite graph In general graphs - not true Example: minimum cover maximum matching

5 Homework solutions Problem 1: Translate node weighted graph G= (G,V,w), where w: V  R +, into edge weighted graph G’=(V,E,w’), w: E  R +, then apply Dijkstra on G’. w1 w2 w3 w4 w5 w6 e w(e)= w1+w2 2 w1+w3 2 For any edge e=v i v k  E we define w’(e)=1/2 [w(v i )+w(v k )]. Then length(v 0 v 1...v n -path in G)=length (v 0 v 1...v n -path in G’)+ 1/2 w(v 0 ) + 1/2 w(v n ) (v 0 =source, v n = sink). The minimum weight path in G corresponds to a minimum weight path in G’. v1

6 Homework solutions Problem 2: For G=(V,E,w) we define a bipartite graph G’= (V+V’,E’,w’) : w(v 2 ) =1 3 3 v1v1 v2v2 v3v3 2 3 2 v1v1 v2v2 v3v3 v1’v1’v2’v2’v3’v3’ 3 1 3 2 2 For each v  V define a “copy” v’ and an edge (v,v’), where w(v,v’)=w(v) (corresponds to a loop in v in graph G) Every edge (u,v)  E replace by 2 edges: (u,v’) and (u’,v) with the same weight as (u,v) G’ is bipartite (every edge has 1 end in V, other in V’) Every path from v 1 to v n = even Every path from v 1 to v n ’ (“copy” of v n ) = odd V V’

7 Homework solutions Problem 3: G=(V,E,w). For each v  V define k “copies” : v 1,v 2,..., v k Then create a directed graph G’=(V’,E’,w’), where V’=V  V 1 ...  V k, v i 1  V 1,.... v j k  V k 1 1 2 2 k k u v For each edge (u,v)  E define edges (u, v 1 ), (u 1, v 2 ), (u 2, v 3 ),... (u (k-1), v k ) with the same edge weight as (u,v). We look at all paths from v 1 (source) to v n (sink) or any copy of v n. All such paths have at most k edges. k  k edges shortest paths


Download ppt "Matching in bipartite graphs Given: non-weighted bipartite graph not covered node extending alternating path initial matching Algorithm: so-called “extending."

Similar presentations


Ads by Google