Midterm < 20 1 20-29 0 30-39 4 40-49 5 50-59 9 60-69 7  70 3.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Graph Algorithms
Advertisements

Min-Max Relations, Hall’s Theorem, and Matching-Algorithms Graphs & Algorithms Lecture 5 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Single Source Shortest Paths
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
 2004 SDU Lecture9- Single-Source Shortest Paths 1.Related Notions and Variants of Shortest Paths Problems 2.Properties of Shortest Paths and Relaxation.
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Tirgul 12 Algorithm for Single-Source-Shortest-Paths (s-s-s-p) Problem Application of s-s-s-p for Solving a System of Difference Constraints.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lectures 3 Tuesday, 9/25/01 Graph Algorithms: Part 1 Shortest.
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Matchings Lecture 3: Jan 18. Bipartite matchings revisited Greedy method doesn’t work (add an edge with both endpoints free)
Chapter 9: Greedy Algorithms The Design and Analysis of Algorithms.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Shortest Paths Definitions Single Source Algorithms
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
CTIS 154 Discrete Mathematics II1 8.2 Paths and Cycles Kadir A. Peker.
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
All-Pairs Shortest Paths
3/24/03Tucker, Section 4.31 Tucker, Applied Combinatorics, Sec. 4.3, prepared by Jo E-M Bipartite GraphMatching Some Definitions X-Matching Maximal Matching.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
CS223 Advanced Data Structures and Algorithms 1 The Bellman-Ford Shortest Path Algorithm Neil Tang 03/11/2010.
1 WEEK 9-10 Graphs II Unweighted Shortest Paths Dijkstra’s Algorithm Graphs with negative costs Acyclic Graphs Izmir University of Economics.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graph (II) Shortest path, Minimum spanning tree GGuy
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm.
 2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Minimum weight spanning trees
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
Bipartite Matching. Unweighted Bipartite Matching.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Introduction to Graph Theory
C&O 355 Lecture 19 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
Proof of correctness of Dijkstra’s algorithm: Basically, we need to prove two claims. (1)Let S be the set of vertices for which the shortest path from.
Trees.
IOI/ACM ICPC Training 4 June 2005.
Proof technique (pigeonhole principle)
Minimum Spanning Trees
Graph theory Definitions Trees, cycles, directed graphs.
Algorithms and Networks
Maximum Flow - Best algorithms
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Special Graphs: Modeling and Algorithms
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Chapter 5. Optimal Matchings
Topological Sort (topological order)
Bipartite Matching and Other Graph Algorithms
Minimum-Cost Spanning Tree
Analysis of Algorithms
Minimum-Cost Spanning Tree
Minimum-Cost Spanning Tree
CS 583 Analysis of Algorithms
Problem Solving 4.
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Richard Anderson Lecture 5 Graph Theory
Special Graphs: Modeling and Algorithms
Minimum-Cost Spanning Tree
Presentation transcript:

Midterm <  70 3

Matchings matching M = subgraph with vertices of degree  1

Matchings = unmatched vertex (vertex not in M) matching M = subgraph with vertices of degree  1

Matchings matching M = subgraph with vertices of degree  1 = unmatched vertex (vertex not in M) perfect matching = matching with no unmatched vertices (perfect world – everybody has a buddy)

Perfect matching

Maximal / maximum maximal = no edge can be added to M to make a bigger matching maximum = there is no matching with more edges maximal, NOT maximum maximum  maximal

Augmenting path path connecting two unmatched vertices with alternating non-matching and matching edges If there exists augmenting path then the matching is NOT maximum.

Augmenting path path connecting two unmatched vertices with alternating non-matching and matching edges

Augmenting path path connecting two unmatched vertices with alternating non-matching and matching edges Lucky ?

Augmenting path Lucky ? NO Theorem: If matching M is not maximum then there exists an augmenting path.

Augmenting path Theorem: If the matching M is not maximum then there exists an augmenting path. M = matching, not maximum B = bigger matching

Proof M = matching, not maximum B = bigger matching MBMB

Proof M = matching, not maximum B = bigger matching MBMB

Proof M = matching, not maximum B = bigger matching MBMB

Proof M = matching, not maximum B = bigger matching MBMB vertices of degree 0,1,2  paths and cycles no odd cycles must have a path with more edges from B than from M  augmenting path

How to find maximum matching? M  repeat find augmenting path P M  M  P until no augmenting path

Augmenting path in bipartite graphs augmenting path has odd length  endpoints on different sides call the one on the left start non matching edges matching edges

Augmenting path in bipartite graphs augmenting path has odd length  endpoints on different sides call the one on the left start non matching edges matching edges

Augmenting path in bipartite graphs augmenting path has odd length  endpoints on different sides call the one on the left start non matching edges matching edges Theorem: augmenting path exists  there is a path from unmatched vertex on the left to an unmatched vertex on the right

Augmenting path in bipartite graphs augmenting path has odd length  endpoints on different sides call the one on the left start non matching edges matching edges Theorem: augmenting path exists  there is a path from the blue vertex on the left to the blue vertex on the right

Augmenting path in bipartite graphs Finding augmenting path (or checking none exists) one BFS (or DFS) computation TIME = O(E) Finding max-matching O( VE ) M  repeat find augmenting path P M  M  P until no augmenting path

Maximum-weight matchings

Maximum-weight matchings weight = 30 maximum-weight matching doesn’t have to be maximum cardinality !!!

Augmenting path path connecting two unmatched vertices with alternating non-matching and matching edges   w e >  w f e  P  M C f  P  M must gain by the swap:

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges THEOREM:

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges Proof: B = max-weight with k+1 edges M  B

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges Proof: B = max-weight with k+1 edges M  B gain = 0

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges Proof: B = max-weight with k+1 edges M  B gain = 0

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges Proof: B = max-weight with k+1 edges M  B gain = 0

Augmenting greedily Assume M = matching of the maximum-weight among matchings with k edges P = augmenting path with maximum gain Then M  P = matching of the maximum weight among matchings with k+1 edges Proof: B = max-weight with k+1 edges M  B gain = wt(B) – wt(M)

How to find maximum-weight matching? M  repeat find augmenting path P with maximum gain M  M  P until no augmenting path only need O(V) iterations

How to find augmenting path with the maximum gain? + -

SHORTEST PATH PROBLEM How to find augmenting path with the maximum gain? + -

NEGATIVE CYCLE? How to find augmenting path with the maximum gain? + -

NEGATIVE CYCLE? How to find augmenting path with the maximum gain? + - impossible – would contradict maximality (among matchings of cardinality k)

How to find augmenting path with the maximum gain? no negative cycles  can use Bellman-Ford to find the shortest path (and hence get augmenting path with the maximum gain)

Putting it all together M  repeat find augmenting path P with maximum gain M  M  P until no augmenting path only need O(V) iterations O(VE) time per iteration (Bellman-Ford) O(V 2 E) time total

Putting it all together M  repeat find augmenting path P with maximum gain M  M  P until no augmenting path only need O(V) iterations O(Vlog V + E) time per iteration (Dijkstra) O(V 2 log V + VE) time total

Back to midterm

Linear ordering of vertices of a directed acyclic graph such that no edges point backward.

2 log n = n n 1/log n = (2 log n ) 1/log n = 2 (log n)/log n = 2 n 2/log n = (2 log n ) 2/log n = 2 2(log n)/log n = 4 1 n 1 + 1/log n = n. n 1/log n = 2n n n 2 binomial(n,2)=n(n-1)/2

Mergesort reduces an instance of size n to 2 instances of size n/2 and the reduction takes time  (n).

Assume that all degrees  2. Then 2 |E| =  deg(v)   2 = 2 n vVvVvVvV Hence there is a vertex of degree  1. There cannot be a vertex of degree 0, since G is connected and |V|  2. Hence there is a vertex of degree = 1.

max { E[ i ], O[ j ] + 1} max { O[ i ], E[ j ] + 1}

max { B[i-1], B[i-2] + a i }

for i from 1 to n do for j from 1 to n do A[i,j]  (A[i,j] + (i+j)) mod 2 M 1  largest all-ones square M 2  largest all-zeros square return max (M 1, M 2 )

for i from 1 to n do for j from 1 to n do M[i,j]  1 if i>1 and j>1 then if (A[i,j]=A[i-1,j-1]) and (A[i,j]  A[i-1,j]) and (A[i,j]  A[i,j-1]) M[i,j]  1+min(M[i-1,j],M[i,j-1],M[i-1,j-1]) return max M[i,j] i,j  {1,...,n}

Extract-Min(H) min  H[1] H[1]  H[n] n  n-1 Heapify(H,1) return min H = heap n = size of the heap

input: weighted, undirected graph G (given by adjacency list) output: minimum-cost spanning tree of G (cost of a tree is the sum of the weights of its edges)