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

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

Solving problems on graph algorithms

Lecture 3: Graphs and flows

Matching Theory. Figure 1: Is this graph bipartite?

CS200: Graphs. Prichard Ch. 14 Rosen Ch. 10. CS200 - Graphs 1

Maximum flows & Maximum Matchings

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

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

GRAPHS Lecture 17 CS2110 Spring 2014

Source. Sink. Chapter 10: Iterative Programming Maximum Flow Problem. CmSc250 Intro to Algorithms

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

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

GRAPHS Lecture 19 CS2110 Spring 2013

Graph Algorithms (part 3 of CSC 282),

CMPSCI611: The SUBSET-SUM Problem Lecture 18

1 Matchings in Graphs

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

Introduction to Graph Theory

LECTURES 3 and 4: Flows and Matchings

GRAPH THEORY and APPLICATIONS. Matchings

Minimum Spanning Tree (undirected graph)

Outline. Graphs. Divide and Conquer.

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

Graph Algorithms (part 3 of CSC 282),

Math 776 Graph Theory Lecture Note 1 Basic concepts

Network flows and Menger s theorem

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

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

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

Cuts, Connectivity, and Flow

Graphs - I CS 2110, Spring 2016

Graphs. Pseudograph: multiple edges and loops allowed

Definition 1.1. A matching M in a graph G is called maximal if there is no matching M in G so that M M.

Graph Algorithms Matching

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

1 Digraphs. Definition 1

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95

BIL694-Lecture 1: Introduction to Graphs

Tutorial for Algorithm s Theory Problem Set 5. January 17, 2013

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

CSC 8301 Design & Analysis of Algorithms: Linear Programming

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Graph Theory: Matchings and Factors

Network Flow and Matching

Discrete mathematics II. - Graphs

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

Chapter 9 Graph Algorithms

1 Matching in Non-Bipartite Graphs

(Re)Introduction to Graphs and Some Algorithms

Chapter 2 Graphs. 2.1 Definition of Graphs

Matching and Covering

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

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

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

Graph. Vertex. edge. Directed Graph. Undirected Graph

Algorithms. Graphs. Algorithms

Lecture 10 Graph algorithms: testing graph properties

Graphs (MTAT , 6 EAP) Lectures: Mon 14-16, hall 404 Exercises: Wed 14-16, hall 402

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Network Flow. By: Daniel Pham, Anthony Huber, Shaazan Wirani

Graphs: Introduction. Ali Shokoufandeh, Department of Computer Science, Drexel University

Simple graph Complete graph K 7. Non- connected graph

Network Basics. CMSC 498J: Social Media Computing. Department of Computer Science University of Maryland Spring Hadi Amiri

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.

0.0.1 Network Analysis

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

Matchings in Graphs. Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1.

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching

Matchings and Covers in bipartite graphs

Bipartite Perfect Matching in O(n log n) Randomized Time. Nikhil Bhargava and Elliot Marx

6. Lecture notes on matroid intersection

Network Flow. The network flow problem is as follows:

Graphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Some Graph Theory for Network Analysis. CS 249B: Science of Networks Week 01: Thursday, 01/31/08 Daniel Bilar Wellesley College Spring 2008

CS261: Problem Set #1

Parallel Breadth First Search

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Algorithm Design (8) Graph Algorithms 1/2

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

CMSC 380. Graph Terminology and Representation

COMP 251 Winter 2017 Online quizzes with answers

A New Parallel Algorithm for Connected Components in Dynamic Graphs. Robert McColl Oded Green David Bader

Graph Algorithms. Andreas Klappenecker

UNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.

Notes for Lecture 20

GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS. March 3, 2016

BT, BST, AVL. Web Resources page on textbook website:

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

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

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

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

Graph and Digraph Glossary

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

List of Theorems. Mat 416, Introduction to Graph Theory. Theorem 1 The numbers R(p, q) exist and for p, q 2,

Ma/CS 6b Class 2: Matchings

Copyright 2000, Kevin Wayne 1

Graphs. Introduction To Graphs: Exercises. Definitions:

Transcription:

(p 186) Graphs G = (V,E) Graphs set V of vertices, each with a unique name Note: book calls vertices as nodes set E of edges between vertices, each encoded as tuple of 2 vertices as in (u,v) Edges may be directed (from u to v) or undirected Undirected edge eqvt to pair of directed edges Example of undirected graph Labeled graph: each edge has a name Weighted graph: each edge has numerical value E.g. in graph of V=cities, weight on (u,v) is distance from u to v 1

Terminology about Graphs (see P. 12) Outdegree of a vertex u: # of edges leaving it i.e. {(u, v)} for some v Indegree of a vertex v: # of edges entering it i.e. {(u, v)} for some u For undirected graph outdegree(u) = indegree(u) = degree(u) K-regular: every vertex has degree k (p. 13) Subgraph: subsets V and E of V and E where all edges in E are between vertices in V Path of length k: from u to v if a set of k edges in G (u i,v i ), 1 i k, where u 1 = u, v i = u i+1, and v k = v Simple path: no vertices are repeated Shortest path: between u & v is simple path of shortest lengthg Diameter: longest shortest path between any 2 vertices Hamiltonian Path: goes thru every vertex once Cycle: a path exists from u back to u 2

Connected iff every vertex can be reached from every other vertex by some path Strongly connected iff a directed path from each vertex to every other Tree: graph with no simple paths: Has root & leaves Vertex Cover of size k: subset of k vertices where every edge touches at least one of them (p. 312) K-Clique: subset of k vertices where there is an edge between every pair in it. Two graphs G & H are isomorphic if vertices of one can be reordered so that graphs are identical Spanning Tree: subgraph that forms a tree that includes all vertices, but with minimum # of edges Flow Network: directed weighted graph where: Each edge can carry a flow (a number) Each edge has a capacity (max possible flow value) For each vertex, incoming flow = outgoing flow Except for some source that generates out flow And some sink which has no outgoing flow 3

Graph Data Structures Assume V = N, E = M Adjacency Matrix: NxN Boolean matrix A where A[u,v] = 1 if (u,v) in E A[u,v] = 0 otherwise If graph is weighted, A[u,v] = weight on (u,v) CSR (Compressed Sparse Row): 3 vectors A: M vector of weights (one per edge) JA: M vector of vertex indecies IA: N+1 vector of indices into A, JA IA[u] = index into A, JA for 1 st edge from u JA[IA[u]] thru JA[IA[u+1]-1] are the v s for edges (u,v) Matching elements in A are weights Lots of variations 4

Spanning Trees & BFS Common problem: starting at some vertex u, find tree that reaches as many vertices as possible If all vertices reachable, then a spanning tree Common algorithm: BFS (Breadth First Search) Frontier: set of all vertices that have been reached for 1 st time At start, just u Also each vertex can be marked as touched or not At start only u so marked For each vertex in current frontier: Follow each outgoing edge If other vertex is not touched: Mark as touched Add to new frontier When frontier empty, swap with new frontier and repeat Option: when first touched, mark vertex with level Level = # of edges from root u At end, final level = diameter of reached subgraph Clearly polynomial time 5

Basis for the GRAPH500 benchmark www.graph500.org Search graphs with up to trillions of vertices Literally thousands of different implementations on different computers, esp. parallel Established by an ND quad-domer Beamer s Algorithm: When frontier too large, instead explore all non-touched If any of them have an edge to current touched, mark them as touched Can reduce time by 10X 6

Maximum Flow Problems Max flow: given a flow network, find largest flow from source to sink where no edge exceeds its capacity Ford-Fulkerson Algorithm https://en.wikipedia.org/wiki/ford%e2%80%93fulkerson_algorithm Define: c(u,v) = capacity of edge (u, v) f(u,v) = flow on edge (u,v) Residual Network G f (V,E f ) = network with capacity c f (u,v) = c(u,v) f(u,v) ( residual flow ) Finding paths can use BFS Each new path chosen is called augmenting path 7

References: Bipartite Graphs https://en.wikipedia.org/wiki/bipartite_graph Bipartite Graph: 2 disjoint sets of vertices U and V, called parts Every edge connects vertex from U with one from V Matching: subset of edges where no two edges share an endpoint Maximal Matching: edge set is largest possible matching Perfect Matching: U = V = matching set Examples of Bipartite Graphs: Athletes and Teams they played with Actors and Movies they acted in Trains and Stations Social networks All graphs that are trees Graphs that form single cycles with even # vertices Graphs that can be written on a 2D plane without edges crossing 8 By David Eppstein - Own work, Public Domain, https://commons.wikimedia.org/w/index.php?curid=2180227

Properties No odd cycles 2-colorable Kőnig's theorem: # of edges in maximum matching = # of vertices in a minimum vertex cover O(VE) algorithm: Hopcroft-Karp https://en.wikipedia.org/wiki/hopcroft%e2%80%93karp_algorithm Similar to Ford-Fulkerson P k = augmenting path of length k Free vertex does not appear in current matching M Iteratively find augmenting path Use BFS to partition vertices into layers Current free vertices from U are the 1 st layer Pick a free vertex from 1 st level Use BFS to create a tree Alternate edges between not in M and in M Stop tree if reach a free vertex u from U 9

Ends at level k when 1 free vertices in V are reached Define free vertices v from V into a set F Choose some shortest tree and then shortest path Called augmenting path (of length k) Remove all edges from M that are in the path Add in all edges from path that are not in M Repeat until no free vertex from U has an augmenting path to a free vertex in V Why does this work? At each iteration, always adding 1 more edge to M than deleting Guaranteed to stop at min( U, V ) Complexity: for each vertex in V may look at each edge in E 10