Special Graphs: Modeling and Algorithms

Slides:



Advertisements
Similar presentations
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 8 Network models.
Advertisements

Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
Network Optimization Models: Maximum Flow Problems
The Maximum Network Flow Problem. CSE Network Flows.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
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.
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,
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Lecture 13 Graphs. Introduction to Graphs Examples of Graphs – Airline Route Map What is the fastest way to get from Pittsburgh to St Louis? What is the.
Computer Science 112 Fundamentals of Programming II Introduction to Graphs.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Data Structures & Algorithms Graphs
CS 4407, Algorithms University College Cork, Gregory M. Provan Network Optimization Models: Maximum Flow Problems In this handout: The problem statement.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
CS 361 – Chapter 16 Final thoughts on minimum spanning trees and similar problems Flow networks Commitment: –Decide on presentation order.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
Introduction to Graph Theory
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Maximum Flow - Anil Kishore Graph Theory Basics. Prerequisites What is a Graph Directed, Weighted graphs How to traverse a graph using – Depth First Search.
The Maximum Network Flow Problem
Programming Abstractions Cynthia Lee CS106B. Upcoming Topics Graphs! 1.Basics  What are they? How do we represent them? 2.Theorems  What are some things.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
Network Flow.
The Maximum Network Flow Problem
Graphs Representation, BFS, DFS
School of Computing Clemson University Fall, 2012
Greedy Technique.
BIPARTITE GRAPHS AND ITS APPLICATIONS
CS4234 Optimiz(s)ation Algorithms
Graph theory Definitions Trees, cycles, directed graphs.
Algorithms and Networks
Maximum Flow - Best algorithms
Algorithm Design and Analysis
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Network Flow.
Special Graphs: Modeling and Algorithms
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
ADVANCED ALGORITHMS GRAPH ALGORITHMS (UNIT-2).
Topological Sort (topological order)
Bipartite Matching and Other Graph Algorithms
The Taxi Scheduling Problem
Graph Algorithm.
Graphs Representation, BFS, DFS
Instructor: Shengyu Zhang
Analysis of Algorithms
Approximation Algorithms
Vertex Covers, Matchings, and Independent Sets
Problem Solving 4.
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Flow Networks and Bipartite Matching
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Weighted Graphs & Shortest Paths
Text Book: Introduction to algorithms By C L R S
Network Flow.
Network Flow.
Maximum Bipartite Matching
Vertex Covers and Matchings
Presentation transcript:

Special Graphs: Modeling and Algorithms

Flow graph modeling Often, recognizing a task as network flow is biggest challenge. Example: Some number of users brings a set of applications (label ‘A’ to ‘Z’) to be run. There are 10 computers that can run applications (1 per day). Applications can only run on certain computers Create nodes for each application, each computer Create single source and single sink Create edge from source to each application node Set weight as the number of that application submitted by users Create edge from application node to computer nodes that can run it Weight can be 1, since only 1 program can run per computer Create edge from computer nodes to the sink Weight is 1, since each can run one program.

Another example (UVA problem 11380) – Titanic sinking Grid of values: water (impassible) – ice with a person on it (will disappear once they leave), ice a person can move to (but will sink once they leave), iceberg (can hold people but not permanently), large wood (can hold people for safety, but only limited number) Create graph connecting adjacent nodes, high edge capacity Set node capacity for ice to 1 Create a source to all nodes with starting people (high edge weight) Create a sink from all wood nodes with weight equal to max. wood capacity.

Edge-disjoint paths Paths in graphs – how many paths do not share an edge Convert each edge to a unit-weight edge If the graph is undirected, form two edges for each (one per direction) Max flow in the graph is the number of edge-disjoint paths

Bipartite graph and Bipartite matching Divide into two groups, A and B All edges are from something in group A to something in group B Bipartite matching Want to uniquely match one item from group A with one item in group B Called Maximum Cardinality Bipartite Matching (MCBM) Notice: Bipartite matching must have bipartite graph where |A| = |B| Given a bipartite graph, can do analysis to find a MCBM

Maximum Cardinality Bipartite Matching Assign a source with an edge to every vertex in set 1 Assign a sink with an edge from every vertex in set 2 Run Max Flow If it can find flow of amount equal to |A| (and therefore |B|), we have a match If sets are unequal size, will find the best possible match (all of one should match to something from other, if possible)

Max Independent Set and Min Vertex Cover Independent Set: no two vertices in set have edge between them Vertex Cover: every vertex is adjacent to some vertex in the set Number of vertices in max independent set is total number minus number in MCBM First form a bipartite graph from elements, then run MCBM on that. Number of vertices in min vertex cover is number in MCBM Note that finding these is a little different (but can use the MCBM matching for this)

MCBM with Augmenting Paths Easier to implement than Max Flow for MCBM Augmenting path: Start at a free vertex (on “left”) Find a free edge to a vertex on “right”. Assume it is already matched. Follow the matched edge from right nodeback to the “left” Repeat until reaching a free vertex on the right i.e., follow “free” edges from left to right, and “matched” from right to left until you hit an unmatched node on the right. Then, reverse the order of all edges visited (from “free” <-> “matched”) Easy to implement (relatively) and fast enough on most cases.

Circulation Each node has either supply or demand, edges have capacity Create a new source with edges to the nodes with supply Edge weights are the amount of supply (negated) Create a new sink with edges from the nodes with demand Edge weights are the amount of demand Then, just run max flow! Several problems can be modeled as circulation problems

Other Graph Types DAG (Directed Acyclic Graph) Tree Eulerian Graph Graph with an Eulerian path or tour: visits each edge exactly once Several algorithms can be simplified if the graph is of one of these types See book for examples

Graph problems vs. DP problems Many DP problems can be rewritten as graph problems on a DAG (not necessarily better, just different). e.g. For coin change, make a node for each possible value. Create an (unweighted) edge from node X to node X-v for each coin denomination v. Then, shortest path (found by BFS) is fewest coins to use. e.g. For 0-1 knapsack, form “levels” of nodes. Level x indicates items 1-x have been processed (so, level 0 is no items, level 1 is 1 item, level 2 is first 2 items, etc.). Within a level, have a node for each value of possible weight remaining. In level 0, only 1 node needed: amount of weight knapsack holds. In level 1, there will be 2 nodes needed: one with max knapsack weight, one with amount minus weight of item 1. etc. From each node of level x, make edges to 2 nodes in level x+1, one for taking item x+1, and one for not taking item x+1. Each edge has the value of that item (if representing “taking”) or 0 (if representing “not taking”) The LONGEST path through graph is maximum value you can get