Syllabus. simple: no multi-edges undirected edges in-/out-/degree /0: absent 1: present (strongly) connected component subgraph, induced graph

Similar documents
Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network

Minimum Spanning Tree (undirected graph)

Graph Algorithms (part 3 of CSC 282),

Jessica Su (some parts copied from CLRS / last quarter s notes)

Today. Maximum flow. Maximum flow. Problem

We ve done. Introduction to the greedy method Activity selection problem How to prove that a greedy algorithm works Fractional Knapsack Huffman coding

Graph Algorithms (part 3 of CSC 282),

Network flows and Menger s theorem

K 4 C 5. Figure 4.5: Some well known family of graphs

Graph Algorithms Using Depth First Search

Chapter 23. Minimum Spanning Trees

Taking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution

Undirected Graphs. Hwansoo Han

CS261: Problem Set #2

Week 11: Minimum Spanning trees

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

Week 12: Minimum Spanning trees and Shortest Paths

CS 561, Lecture 9. Jared Saia University of New Mexico

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

Solving problems on graph algorithms

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

Index. stack-based, 400 A* algorithm, 325

Graphs. Edges may be directed (from u to v) or undirected. Undirected edge eqvt to pair of directed edges

Maximum flows & Maximum Matchings

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI. Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

22 Elementary Graph Algorithms. There are two standard ways to represent a

Minimum Spanning Trees

Minimum Spanning Trees

Unweighted Graphs & Algorithms

Matching in Bipartite Graphs

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Parallel Breadth First Search

Introduction to Graph Theory

Classic Graph Theory Problems

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

Dijkstra s algorithm for shortest paths when no edges have negative weight.

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

Analysis of Algorithms, I

Graph Theory. ICT Theory Excerpt from various sources by Robert Pergl

Minimum Spanning Trees

Minimum Spanning Tree (5A) Young Won Lim 5/11/18

Outline. Graphs. Divide and Conquer.

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Lecture 6 Basic Graph Algorithms

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Shortest Paths: Basics. Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender

Minimum Spanning Trees

CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016

Problem Set 2 Solutions

Advanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012

Minimum Spanning Trees My T. UF

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Shortest path problems

Minimum spanning trees

Graph Algorithms. Textbook reading. Chapter 3 Chapter 4. CSci 3110 Graph Algorithms 1/41

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

What is a minimal spanning tree (MST) and how to find one

Approximation slides 1. An optimal polynomial algorithm for the Vertex Cover and matching in Bipartite graphs

2 A Template for Minimum Spanning Tree Algorithms

Theory of Computing. Lecture 7 MAS 714 Hartmut Klauck

Shortest Paths: Algorithms for standard variants. Algorithms and Networks 2017/2018 Johan M. M. van Rooij Hans L. Bodlaender

Announcements Problem Set 5 is out (today)!

CS4800: Algorithms & Data Jonathan Ullman

END-TERM EXAMINATION

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Cuts, Connectivity, and Flow

GRAPHS Lecture 17 CS2110 Spring 2014

Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees

Chapter 9 Graph Algorithms

CSC 8301 Design & Analysis of Algorithms: Kruskal s and Dijkstra s Algorithms

CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Lecture 3: Graphs and flows

Student Name and ID Number. MATH 3012, Quiz 3, April 16, 2018, WTT

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Communication Networks I December 4, 2001 Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page 1

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Dan Grossman Fall 2013

1. Let n and m be positive integers with n m. a. Write the inclusion/exclusion formula for the number S(n, m) of surjections from {1, 2,...

Network Design and Optimization course

Graph Algorithms. A Brief Introduction. 高晓沨 (Xiaofeng Gao) Department of Computer Science Shanghai Jiao Tong Univ.

Algorithm Design and Analysis

CS350: Data Structures Dijkstra s Shortest Path Alg.

Weighted Graph Algorithms Presented by Jason Yuan

LECTURES 3 and 4: Flows and Matchings

Number Theory and Graph Theory

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10

Algorithms and Data Structures: Minimum Spanning Trees (Kruskal) ADS: lecture 16 slide 1

Chapter 9 Graph Algorithms

Introductory Remarks

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

Transcription:

Introduction to Algorithms Syllabus Recap on Graphs: un/directed, weighted Shortest Paths: single-source, all-pairs Minimum Spanning Tree: Prim, Kruskal Maximum Flow: Ford-Fulkerson, Edmonds-Karp Maximum (weighted) Bipartite Matching Minimum Cut graph recap Basic graph concepts: E V V directed edges simple: no multi-edges nor loops E symmetric: undirected edges in-/out-/degree /0: absent (un-/directed) path w:e edge weights 1: present (strongly) connected component subgraph, induced graph Handshaking lemma: #E = v V indeg(v) = v V outdeg(v) Adjacency/weight matrix A G V V Powers of A G

graph examples diameter? planar? Connectedness ; s,t V DFS(v) // Is t reachable in G from v? If v is marked visited Return (false); If v=t Return (true); Mark v as visited; For each neighbor u of v do if DFS(u) Return (true); Return (false); Adjacency/weight matrix A G Output: Is there a (directed) path from s to t in G? Reachable(G,s,t) For each vertex v V Mark v as unvisited; Return DFS(s) A u,v = no edge A u,u = 0

Shortest path(s) ; s,t V s V Adjacency/weight matrix A G Output: For every t V, weight d(s,t) of lightest path from s to t. Dijkstra s s Algorithm: Mark all vertices Initialize Q:= :=V. set of unvisited vertices vertices unvisited visited. For each vertex v let d v := ; d s :=0. While Q do Extract from Q a vertex u with least d u. Mark u as visited. For each unvisited neighbor u of v do If d':= :=d u +A uv < d v tentative distance from s Correctness??? then decrease d v :=d' d'. O(n extractmin+ m decreasekey) array array O(n n+m 1) All shortest paths Adjacency/weight matrix A G Output: For every t V, weight d(s,t) of lightest path from s to t. Loop invariant d v d(s,v). Suppose M := { v : d v > d(s,v) ) }. Then δ := min{ d(s,v) ) : v M } and v M For (s,, u, v) Thus d(s,v)= d(s,u)+ )+A uv with d(s,v)= )=δ exist. a lightest path to v, it holds δ > d(s,u) = d u. and u gets extracted from Q before v. While Q do Extract from Q a vertex u with least d u. Mark u as visited. For each unvisited neighbor u of v do in increasing If d':= :=d u +A uv < d v then decrease d v :=d' d'. order w.r.t. d For correctness, recall main loop: While

All shortest paths Adjacency/weight matrix A G Output: For every all s,t V, weight d(s,t) of lightest path from s to t. Floyd-Warshall Algorithm: For all pairs (u,v)) of vertices, initialize d u,v For each vertex u V For each vertex v V For each vertex w V Correctness? If d v,w > d v,u + d u,w d v,w := d v,u then v,u + d u,w u,v :=A u,v A u,v = no edge A u,u = 0 runtime O(n³) Min. Spanning Tree Symmetric Output: T E spanning tree of least weight s.t. (V,T) connected A u,v = no edge A u,u = 0

Prim s Algorithm Symmetric Output: T E spanning tree of least weight 1. Initialize a tree with a single vertex, chosen arbitrarily from the graph. 2. Grow the tree by one edge: Of the edges that connect the tree to vertices not yet in the tree, find the minimum-weight edge, and transfer it to the tree. 3. Repeat step 2 (until all vertices are in the tree). 11 6 3 6 1 10 12 11 3 12 5 4 10 1 5 2 7 4 2 Prim s Algorithm Symmetric Output: T E spanning tree of least weight Initialize F:= :=, Q:= :=V.. Also: d v := and e v :=0 for all v V. While Q do Extract from Q a vertex u with least d u. If e u 0, add edge (u,e u ) to F. For each neighbor v Q of u do If A uv < d v then decrease d v := A uv ; e v :=u; 11 6 3 6 O(n extractmin+ m decreasekey) 10 1 12 11 3 12 5 4 10 1 5 2 7 4 2

Kruskal Algorithm Symmetric Initialize the forest (=set of trees) with edges F:={} :={},, i.e., such that each vertex v V is a separate tree. While E {} and F is not yet spanning: Extract from E edge e of least weight. If e connects two different trees of F then add e to F,, thus? combining two trees into a single one. Output: T E spanning tree of least weight 11 6 3 O(1) after initial sorting 1 10 12 5 7 7 4 Max Flow Input: s,t V, A G Output: f:e max. flow from s to t Goal: maximize v:( :(s,v) E f(s,v) = u:( :(u,t) E f(u,t) f flow (from s to t) Lemma: There exists an integral maximal flow. Def: A flow from s to t in G with weights A 0 is a function f:e such that v V\{s,t}: u:(u,v) E f(u,v) = w:(v,w) E f(v,w). It is admissible if it holds f(u,v) A u,v

Ford-Fulkerson Input: s,t V, A G Output: f:e max. flow from s to t Goal: maximize f := := The residual G v:( :(s,v) E f(s,v) f of a graph G with flow f has edges E f := { (u,v) : A u,v > f(u,v) f(v,u) > 0 } Def: Ford-Fulkerson A Fulkerson: flow from s to Initialize t in G with f 0. weights Correctness? A 0 is Runtime a function Termination? O(m f ) ) f:e While there such exists that v V\{s,t}: a path P = (s=u u:(u,v) E 1, u K f(u,v) =t) from = s w:(v,w) E to t in Gf(v,w). f It is Let admissible α := min{ if Ait uk holds f(u,v) A,u k+1 +1 f(u k,u k+1 +1) ) : k=1 K 1 u,v 1 } and f := f+α P. Edmonds-Karp Input: s,t V, A G Output: f:e max. flow from s to t Goal: maximize f := := The residual G v:( :(s,v) E f(s,v) f of a graph G with flow f has edges E f := { (u,v) : A u,v > f(u,v) f(v,u) > 0 } Edmonds-Karp Ford-Fulkerson Fulkerson: Karp: Initialize f 0. shortest Runtime O(n m²) O(m f ) ) While there exists a path P = (s=u 1, u K =t) from s to t in G f Let α := min{ A uk,u f(u k+1 k,u k+1) ) : k=1 K 1 1 } and f := f+α P.

Specification: Bipartite graph G=(U,V,E) Output: F E max. (weighted) matching U max. Bipartite Matching U V V Edmonds-Karp Ford-Fulkerson Fulkerson: Karp: Initialize f 0. shortest Runtime O(n m²) While there exists a path P from s to t in G f Let α := min{ A uk,u k+1 +1 f(u k,u k+1 +1) ) : k=1 K 1 1 } and f := f+α P. Min Cut Input: s,t V, A G Output: C E min.cut between s,t Def: A cut from s to t in G is a subset C V s.t. s C, t C. It has capacity Theorem: capacity λ(c) = (u,v) E min λ(c) = C cut (s,t) Proof " ":": For every C,f: λ(c) f.. " ":": Consider C V all vertices reachable Goal: minimize imize λ(c) : C cut (s,t) from s in G f for max. f from Ford-Fulkerson. Fulkerson. u C,v C max f f flow (s,t) A u,v