Warshall s Algorithm: Transitive Closure



Similar documents
Approximation Algorithms

Data Structures and Algorithms Written Examination

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Dynamic programming. Doctoral course Optimization on graphs - Lecture 4.1. Giovanni Righini. January 17 th, 2013

DATA ANALYSIS II. Matrix Algorithms

5 INTEGER LINEAR PROGRAMMING (ILP) E. Amaldi Fondamenti di R.O. Politecnico di Milano 1

Network (Tree) Topology Inference Based on Prüfer Sequence

Matrix-Chain Multiplication

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Linear Programming. March 14, 2014

Linear Programming. Widget Factory Example. Linear Programming: Standard Form. Widget Factory Example: Continued.

Load balancing in a heterogeneous computer system by self-organizing Kohonen network

Zachary Monaco Georgia College Olympic Coloring: Go For The Gold

Optimization in R n Introduction

Dynamic Programming. Lecture Overview Introduction

5.1 Bipartite Matching

A permutation can also be represented by describing its cycles. What do you suppose is meant by this?

Exam study sheet for CS2711. List of topics

Solutions to Homework 6

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

SECTIONS NOTES ON GRAPH THEORY NOTATION AND ITS USE IN THE STUDY OF SPARSE SYMMETRIC MATRICES

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Social Media Mining. Graph Essentials

Any two nodes which are connected by an edge in a graph are called adjacent node.

FUZZY CLUSTERING ANALYSIS OF DATA MINING: APPLICATION TO AN ACCIDENT MINING SYSTEM

An Introduction to APGL

CSC2420 Spring 2015: Lecture 3

(67902) Topics in Theory and Complexity Nov 2, Lecture 7

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Discrete Mathematics. Hans Cuypers. October 11, 2007

Discuss the size of the instance for the minimum spanning tree problem.

MANAGEMENT OPTIMIZATION PROBLEMS ON FUZZY GRAPHS

Part 2: Community Detection

2.8 An application of Dynamic Programming to machine renewal


Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Static Load Balancing

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Algorithm for payoff calculation for option trading strategies using vector terminology

Scheduling Shop Scheduling. Tim Nieberg

Practical Graph Mining with R. 5. Link Analysis

A linear combination is a sum of scalars times quantities. Such expressions arise quite frequently and have the form

Introduction to Logic in Computer Science: Autumn 2006

Applied Algorithm Design Lecture 5

Max Flow, Min Cut, and Matchings (Solution)

Graph Processing and Social Networks

Cpt S 223. School of EECS, WSU

Nimble Algorithms for Cloud Computing. Ravi Kannan, Santosh Vempala and David Woodruff

. P. 4.3 Basic feasible solutions and vertices of polyhedra. x 1. x 2

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Discrete Optimization

USING SPECTRAL RADIUS RATIO FOR NODE DEGREE TO ANALYZE THE EVOLUTION OF SCALE- FREE NETWORKS AND SMALL-WORLD NETWORKS

A Review And Evaluations Of Shortest Path Algorithms

Lecture 11: 0-1 Quadratic Program and Lower Bounds

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Linear Programming. April 12, 2005

Matrix Multiplication

NP-Hardness Results Related to PPAD

Statistical machine learning, high dimension and big data

DYNAMIC GRAPH ANALYSIS FOR LOAD BALANCING APPLICATIONS

Algorithm Design and Analysis

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Dynamic programming. Chapter Shortest paths in dags, revisited S C A B D E

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

Lecture 17 : Equivalence and Order Relations DRAFT

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Near Optimal Solutions

We shall turn our attention to solving linear systems of equations. Ax = b

Dantzig-Wolfe bound and Dantzig-Wolfe cookbook

Direct Methods for Solving Linear Systems. Matrix Factorization

Asking Hard Graph Questions. Paul Burkhardt. February 3, 2014

11. APPROXIMATION ALGORITHMS

CS473 - Algorithms I

DETERMINANTS IN THE KRONECKER PRODUCT OF MATRICES: THE INCIDENCE MATRIX OF A COMPLETE GRAPH

1 Introduction. Dr. T. Srinivas Department of Mathematics Kakatiya University Warangal , AP, INDIA

Determinants in the Kronecker product of matrices: The incidence matrix of a complete graph

8.1 Min Degree Spanning Tree

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. The Independent Even Factor Problem

Introduction to Scheduling Theory

SCORE SETS IN ORIENTED GRAPHS

Transportation Polytopes: a Twenty year Update

OPTIMAL DESIGN OF DISTRIBUTED SENSOR NETWORKS FOR FIELD RECONSTRUCTION

Bicolored Shortest Paths in Graphs with Applications to Network Overlay Design

Single machine parallel batch scheduling with unbounded capacity

Using Graph Theory to Analyze Gene Network Coherence

Lecture 1: Course overview, circuits, and formulas

Understanding Complex Network Attack Graphs through Clustered Adjacency Matrices

3/25/ /25/2014 Sensor Network Security (Simon S. Lam) 1

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

6.852: Distributed Algorithms Fall, Class 2

On the k-path cover problem for cacti

Transcription:

CS 0 Theory of Algorithms / CS 68 Algorithms in Bioinformaticsi Dynamic Programming Part II. Warshall s Algorithm: Transitive Closure Computes the transitive closure of a relation (Alternatively: all paths in a directed graph) Example of transitive closure: 3 3 0 0 0 00 0 0 0 0 0 0 Design and Analysis of Algorithms - Chapter 8 8-

Warshall s Algorithm Main idea: a path exists between two vertices i, j, iff there is an edge from i to j; or there is a path from i to j going through vertex ; or there is a path from i to j going through vertex and/or ; or there is a path from i to j going through vertex,, and/or 3; or... there is a path from i to j going through any of the other vertices 3 3 3 3 3 R 0 0 0 0 0 0 0 0 0 R 0 0 0 0 0 0 0 R 0 0 0 0 R 3 0 0 0 0 R 0 0 0 Design and Analysis of Algorithms - Chapter 8 8- Warshall s Algorithm On the k th iteration, the algorithm determine if a path exists between two vertices i, j using just vertices among,,k allowed as intermediate { R (k-) [i,j] (path using just,,k-) R (k) [ij]= [i,j]= or (R (k-) [i,k] and R (k-) [k,j]) (path from i to k k and from k to i using just,,k-) i k th iteration j Design and Analysis of Algorithms - Chapter 8 8-3

Warshall s Algorithm: Transitive Closure Design and Analysis of Algorithms - Chapter 8 8- Warshall s Algorithm (matrix generation) Recurrence relating elements R (k) to elements of R (k-) is: R (k) [i,j] = R (k-) [i,j] or (R (k-) [i,k] and R (k-) [k,j]) It implies the following rules for generating R (k) from R (k-) : Rule If an element in row i and column j is in R (k-), it remains in R (k) Rule If an element in row i and column j is 0 in R (k-), it has to be changed to in R (k) if and only if the element in its row i and column k and the element in its column j and row k are both s inr R (k-)

Warshall s Algorithm: Transitive Closure Design and Analysis of Algorithms - Chapter 8 8-6 Design and Analysis of Algorithms - Chapter 8 8-7

Warshall s Algorithm (pseudocode and analysis) Time efficiency: (n 3 ) Space efficiency: Matrices can be written over their predecessors Floyd s Algorithm: All pairs shortest paths Problem: In a weighted (di)graph, find shortest paths between every pair of vertices Same idea: construct solution through series of matrices D (0),, D (n) using increasing subsets of the vertices allowed as intermediate Example: 3 6 5 3 Design and Analysis of Algorithms - Chapter 8 8-9

Floyd s Algorithm (matrix generation) On the k-th iteration, the algorithm determines shortest paths between every pair of vertices i, j that use only vertices among,,k as intermediate D (k) [i,j] = min {D (k-) [i,j], D (k-) [i,k] + D (k-) [k,j]} D (k-) [i,k] i D (k-) [i,j] j k D (k-) [k,j] Floyd s Algorithm: All pairs shortest paths Design and Analysis of Algorithms - Chapter 8 8-

Design and Analysis of Algorithms - Chapter 8 8- Floyd s Algorithm (pseudocode and analysis) Timeefficiency: ce cy: ( (n 3 ) Space efficiency: Matrices can be written over their predecessors

Knapsack Problem by DP Given n items of integer weights: w w w n values: v v v n a knapsack of integer capacity W find most valuable subset of the items that fit into the knapsack Consider instance defined by first i items and capacity j (j W). Let V[i,j] be optimal value of such instance. Then V[i,j]= max {V[i-,j], v i + V[i-,j- w i ]} if j- w i 0 V[i-,j] if j- w i < 0 Initial conditions: V[0,j] = 0 and V[i,0] = 0 Knapsack Problem by DP (example) Example: Knapsack of capacity W = 5 item weight value $ $0 3 3 $0 $5 capacity yjj 0 3 5 0 w =, v = w =, v = 0 w 3 = 3, v 3 = 0 3 w =, v = 5?

Knapsack Problem V[i, j] = max (V[i, j], V[i, j w i ] + v i ) object i not used object i used Design and Analysis of Algorithms - Chapter 8 8-6 Knapsack Problem V[i, j] = max (V[i, j], V[i, j w i ] + v i ) object i not used object i used Design and Analysis of Algorithms - Chapter 8 8-7

Knapsack Problem Memory Function Implement the recurrence recursively Do not calculate a value if it is not needed Do not recalculate a value Row 0 and column 0 of V are initialized to 0, other entries are - MFKnapsack(i, j) if V[i, j]< 0 if j < w[i] value MFKnapsack(i, j) else value max (MFKnapsack(i, j), MFKnapsack(i,j w[i]) + v[i]) V[i, j] value return V[i, j] Design and Analysis of Algorithms - Chapter 8 8-8 Knapsack Problem Memory Function Design and Analysis of Algorithms - Chapter 8 8-9