2.3.4 Optimal paths in directed acyclic graphs

Size: px
Start display at page:

Download "2.3.4 Optimal paths in directed acyclic graphs"

Transcription

1 .3.4 Optimal paths in directed acyclic graphs Definition: A directed graph G = (N, A) is acyclic if it contains no circuits. A directed acyclic graph is referred to as DAG. circuit Problem Given a directed acyclic G = (N, A) with a cost c ij for each (i, j) A, and nodes s and t, determine a shortest (longest) path from s to t. E. Amaldi Foundations of Operations Research Politecnico di Milano

2 Property The nodes of any directed acyclic graph G can be ordered topologically, that is, indexed so that for each arc (i, j) A we have i < j. Topological order Such a topological order can be exploited in a very efficient Dynamic Programming algorithm to find shortest (or longest) paths in directed acyclic graphs. E. Amaldi Foundations of Operations Research Politecnico di Milano

3 Topological ordering method G = (N, A) is represented via the lists of predecessors - (v) and successors + (v) for each node v - (v ) + (v). Assign the smallest positive integer not yet assigned to a node v N with - (v) =. such a node v exists because G does not contain circuits v. Delete the node v with all its incident arcs. 3. Go back to. until there are nodes in the current subgraph. E. Amaldi Foundations of Operations Research Politecnico di Milano 3

4 Example G E. Amaldi Foundations of Operations Research Politecnico di Milano 4

5 etc... Complexity: O(m) where m= A because each node and each arc is considered at most once. E. Amaldi Foundations of Operations Research Politecnico di Milano 5

6 Example G s t 3 Given G and a topological order of the nodes, find a shortest path from node to node? E. Amaldi Foundations of Operations Research Politecnico di Milano

7 Dynamic Programming for shortest paths in DAGs Any shortest path t : t with at least two arcs can be subdivided into two parts i and (i,t): Definition: For each node i =,..., t i t where i : i is a shortest subpath from s to i. i L(i) = cost of a shortest path from to i. c it Clearly L(t) = min { L() i c it } it, ( t ) where the minimum is taken over all possible predecessors i of t in a path from to t. E. Amaldi Foundations of Operations Research Politecnico di Milano

8 If G is directed and acyclic and the nodes are topologically ordered, the only possible predecessors of t in a shortest path t from to t are those with index i < t and hence: L(t) = min{ L( i) c } i t it Observation: In a graph containing circuits, any node different from t can be a predecessor of t in t! E. Amaldi Foundations of Operations Research Politecnico di Milano

9 For DAGs whose nodes are topologically ordered L(t-),... and L() satisfy the same type of recursive relations: min{ Li () } L(t-) = i( t )... i t c min{ L } L() = () i c = L() + c L() = 0 i which can be solved in the reverse order: L() = 0 L() = L() + c i... min{ L c } L(t) = () i i t it E. Amaldi Foundations of Operations Research Politecnico di Milano

10 Example L() = 0 L() = L() + c = = 4 L(3) = L() + c 3 = 0 + = pred()= pred()= pred(3)= L(4) = min{ L( i) c } = min{0 + 5, 4 + 3, + } = 3 i,,3 i 4 pred(4)=3 G s [.] indicates the predecessor of node i in a shortest path from to i E. Amaldi Foundations of Operations Research Politecnico di Milano 0 t

11 L(5) = min{ Li () c } = min { 0 +, 4 + } = 5 i, min{ Li ( ) c } L() = = min { + } = 3 i 3 i5 i L() = L(5) + c 5 = 5 + = pred(5)= pred()=3 pred()=5 L() = min { Li ( ) c } = min { 3+3, 5+, 3+, + } = 4 G i 4,5,, s i pred()= pred(5)= 3 5 shortest path from to of total cost 4 pred()=5 pred()=5 E. Amaldi Foundations of Operations Research Politecnico di Milano t

12 Complexity DP for shortest paths in DAGs BEGIN Sort the nodes of G topologically; L[] := 0; FOR j:= TO n DO /* in topological order */ L[j] := min {L[i] + c ij : (i,j) - (j), i < j}; pred[j] := v with (v,j) = argmin {L[i] + c ij : (i,j) - (j), i < j}; END-FOR END Topological ordering of the nodes: O(m) with m= A Each node and arc are considered exactly once: O(n+m) Overall complexity: O(m) E. Amaldi Foundations of Operations Research Politecnico di Milano

13 Adaptation of DP for longest paths in DAGs Straightforward adaptation of the Dynamic Programming method to find longest paths in directed acyclic graphs: L(t) = max{ Li ( ) c}... i t it E. Amaldi Foundations of Operations Research Politecnico di Milano 3

14 Proposition: The Dynamic Programming algorithm for finding shortest (longest) paths in DAGs is exact. This is due to: Optimality principle For any shortest (longest) path j : j there exists i < j such that we have the decomposition: i j i where the subpath i : i is of minimum (maximum) length from s to i. c ij E. Amaldi Foundations of Operations Research Politecnico di Milano 4

15 Dynamic Programming (DP) Proposed in 53 by Richard Bellman (0-4) General technique in which an optimal solution, composed of a sequence of elementary decisions, is determined by solving a set of recursive equations. DP is applicable to any sequential decision problem for which the optimality property is satisfied. A wide range of applications: optimal control (rocket launch), equipment maintenance and replacement, selection of inspection points along a production line, E. Amaldi Foundations of Operations Research Politecnico di Milano 5

16 Exercise A company buys a new machine for K. Annual maintenance costs for the next five years: Age (years) Maintenance (K ) Recover (K ) To avoid high maintenance costs of an older machine, the machine can be replaced at the beginning of the nd,3 rd,4 th or 5 th year with a new machine. E. Amaldi Foundations of Operations Research Politecnico di Milano

17 To simplify the model, suppose that the cost of a new machine is constant ( K ). Objective: minimize the net total cost ( price + maintenance recover ) over the 5 year horizon. Age 0 Main. Reco. - If we buy a machine at beginning of st year and sell it at the beginning of nd year, the net cost is: + - = If we buy it at the beginning of st year and sell it at the beginning of 3rd year, the net cost is: = etc... E. Amaldi Foundations of Operations Research Politecnico di Milano

18 Show how the problem of determining an optimal maintenance - replacement policy of minimum total cost (for the next 5 years) can be solved via Dynamic Programming. Hint: Reduce it to a minimum cost path problem in an appropriate acyclic graph. Find all the optimal maintenance-replacement policies. E. Amaldi Foundations of Operations Research Politecnico di Milano

2.3 Optimal paths. Optimal (shortest or longest) paths have a wide range of applications:

2.3 Optimal paths. Optimal (shortest or longest) paths have a wide range of applications: . Optimal paths Optimal (shortest or longest) paths have a wide range of applications: Google maps, GPS navigators planning and management of transportation, electrical and telecommunication networks project

More information

2.3 Optimal paths. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

2.3 Optimal paths. E. Amaldi Foundations of Operations Research Politecnico di Milano 1 . Optimal paths E. Amaldi Foundations of Operations Research Politecnico di Milano Optimal (minimum or maximum) paths have a wide range of applications: Google maps, GPS navigators planning and management

More information

2.2 Optimal cost spanning trees

2.2 Optimal cost spanning trees . Optimal cost spanning trees Spanning trees have a number of applications: network design (communication, electrical,...) IP network protocols compact memory storage (DNA)... E. Amaldi Foundations of

More information

2.8 An application of Dynamic Programming to machine renewal

2.8 An application of Dynamic Programming to machine renewal ex-.6-. Foundations of Operations Research Prof. E. Amaldi.6 Shortest paths with nonnegative costs Given the following directed graph, find a set of shortest paths from node to all the other nodes, using

More information

2.3.5 Project planning

2.3.5 Project planning efinitions:..5 Project planning project consists of a set of m activities with their duration: activity i has duration d i, i = 1,..., m. estimate Some pairs of activities are subject to a precedence constraint:

More information

CS420/520 Algorithm Analysis Spring 2009 Lecture 14

CS420/520 Algorithm Analysis Spring 2009 Lecture 14 CS420/520 Algorithm Analysis Spring 2009 Lecture 14 "A Computational Analysis of Alternative Algorithms for Labeling Techniques for Finding Shortest Path Trees", Dial, Glover, Karney, and Klingman, Networks

More information

CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018

CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018 CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018 Q1: Prove or disprove: You are given a connected undirected graph G = (V, E) with a weight function w defined over its

More information

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1 Graph fundamentals Bipartite graph characterization Lemma. If a graph contains an odd closed walk, then it contains an odd cycle. Proof strategy: Consider a shortest closed odd walk W. If W is not a cycle,

More information

7.3 Spanning trees Spanning trees [ ] 61

7.3 Spanning trees Spanning trees [ ] 61 7.3. Spanning trees [161211-1348 ] 61 7.3 Spanning trees We know that trees are connected graphs with the minimal number of edges. Hence trees become very useful in applications where our goal is to connect

More information

Shortest Paths. March 21, CTU in Prague. Z. Hanzálek (CTU) Shortest Paths March 21, / 44

Shortest Paths. March 21, CTU in Prague. Z. Hanzálek (CTU) Shortest Paths March 21, / 44 Shortest Paths Zdeněk Hanzálek hanzalek@fel.cvut.cz CTU in Prague March 21, 2017 Z. Hanzálek (CTU) Shortest Paths March 21, 2017 1 / 44 Table of contents 1 Introduction Problem Statement Negative Weights

More information

Datenstrukturen & Algorithmen Blatt P13 HS 18

Datenstrukturen & Algorithmen Blatt P13 HS 18 Eidgenössische Technische Hochschule Zürich Ecole polytechnique fédérale de Zurich Politecnico federale di Zurigo Federal Institute of Technology at Zurich Departement of Computer Science 3. December 08

More information

Algorithms and Data Structures 2014 Exercises and Solutions Week 9

Algorithms and Data Structures 2014 Exercises and Solutions Week 9 Algorithms and Data Structures 2014 Exercises and Solutions Week 9 November 26, 2014 1 Directed acyclic graphs We are given a sequence (array) of numbers, and we would like to find the longest increasing

More information

Lecture 3: Graphs and flows

Lecture 3: Graphs and flows Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected

More information

COL 702 : Assignment 1 solutions

COL 702 : Assignment 1 solutions COL 70 : Assignment 1 solutions 1(a ( n T (n = T + bn log n ( n = T + b n ( n log + bn log n ( n = T + b n ( n 8 log + b n log ( n + bn log n = bn log n + b n log n + bn log n +... log n terms = nb [(log

More information

Math 381 Discrete Mathematical Modeling

Math 381 Discrete Mathematical Modeling Math 381 Discrete Mathematical Modeling Sean Griffin Today: -Equipment Replacement Problem -Min Spanning Tree Problem -Clustering Friday s Plan Intro to LPSolve software Download before class (link on

More information

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

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other. Directed Graph In a directed graph, each edge (u, v) has a direction u v. Thus (u, v) (v, u). Directed graph is useful to model many practical problems (such as one-way road in traffic network, and asymmetric

More information

Last topic: Summary; Heuristics and Approximation Algorithms Topics we studied so far:

Last topic: Summary; Heuristics and Approximation Algorithms Topics we studied so far: Last topic: Summary; Heuristics and Approximation Algorithms Topics we studied so far: I Strength of formulations; improving formulations by adding valid inequalities I Relaxations and dual problems; obtaining

More information

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation The Shortest Path Problem jla,jc@imm.dtu.dk Department of Management Engineering Technical University of Denmark The Shortest Path Problem Given a directed network G = (V,E,w) for which the underlying

More information

CS261: Problem Set #1

CS261: Problem Set #1 CS261: Problem Set #1 Due by 11:59 PM on Tuesday, April 21, 2015 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. (2) Turn in your solutions by

More information

CS 270 Algorithms. Oliver Kullmann. Analysing BFS. Depth-first search. Analysing DFS. Dags and topological sorting.

CS 270 Algorithms. Oliver Kullmann. Analysing BFS. Depth-first search. Analysing DFS. Dags and topological sorting. General remarks Week 5 2 We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week 5 Chapter

More information

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

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

More information

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

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019 CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction

More information

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs Graphs and Network Flows ISE 411 Lecture 7 Dr. Ted Ralphs ISE 411 Lecture 7 1 References for Today s Lecture Required reading Chapter 20 References AMO Chapter 13 CLRS Chapter 23 ISE 411 Lecture 7 2 Minimum

More information

1 Digraphs. Definition 1

1 Digraphs. Definition 1 1 Digraphs Definition 1 Adigraphordirected graphgisatriplecomprisedofavertex set V(G), edge set E(G), and a function assigning each edge an ordered pair of vertices (tail, head); these vertices together

More information

CSE Winter 2015 Quiz 2 Solutions

CSE Winter 2015 Quiz 2 Solutions CSE 101 - Winter 2015 Quiz 2 s January 27, 2015 1. True or False: For any DAG G = (V, E) with at least one vertex v V, there must exist at least one topological ordering. (Answer: True) Fact (from class)

More information

6. Lecture notes on matroid intersection

6. Lecture notes on matroid intersection Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans May 2, 2017 6. Lecture notes on matroid intersection One nice feature about matroids is that a simple greedy algorithm

More information

Lecture 22 Tuesday, April 10

Lecture 22 Tuesday, April 10 CIS 160 - Spring 2018 (instructor Val Tannen) Lecture 22 Tuesday, April 10 GRAPH THEORY Directed Graphs Directed graphs (a.k.a. digraphs) are an important mathematical modeling tool in Computer Science,

More information

These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.

These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. CSE 591 HW Sketch Sample Solutions These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. Problem 1 (a) Any

More information

U.C. Berkeley CS170 : Algorithms Midterm 1 Lecturers: Alessandro Chiesa and Satish Rao September 18, Midterm 1

U.C. Berkeley CS170 : Algorithms Midterm 1 Lecturers: Alessandro Chiesa and Satish Rao September 18, Midterm 1 U.C. Berkeley CS170 : Algorithms Lecturers: Alessandro Chiesa and Satish Rao September 18, 2018 1 Connectivity in Graphs No justification is required on this problem. A B C D E F G H I J (a) (2 points)

More information

Artificial Intelligence

Artificial Intelligence Artificial Intelligence Shortest Path Problem G. Guérard Department of Nouvelles Energies Ecole Supérieur d Ingénieurs Léonard de Vinci Lecture 3 GG A.I. 1/42 Outline 1 The Shortest Path Problem Introduction

More information

CS 270 Algorithms. Oliver Kullmann. Breadth-first search. Analysing BFS. Depth-first. search. Analysing DFS. Dags and topological sorting.

CS 270 Algorithms. Oliver Kullmann. Breadth-first search. Analysing BFS. Depth-first. search. Analysing DFS. Dags and topological sorting. Week 5 General remarks and 2 We consider the simplest graph- algorithm, breadth-first (). We apply to compute shortest paths. Then we consider the second main graph- algorithm, depth-first (). And we consider

More information

cs/ee 143 Communication Networks

cs/ee 143 Communication Networks cs/ee 143 Communication Networks Chapter 5 Routing Text: Walrand & Parakh, 2010 Steven Low CMS, EE, Caltech Warning These notes are not self-contained, probably not understandable, unless you also were

More information

Basic Graph Definitions

Basic Graph Definitions CMSC 341 Graphs Basic Graph Definitions A graph G = (V,E) consists of a finite set of vertices, V, and a finite set of edges, E. Each edge is a pair (v,w) where v, w V. V and E are sets, so each vertex

More information

EXERCISES SHORTEST PATHS: APPLICATIONS, OPTIMIZATION, VARIATIONS, AND SOLVING THE CONSTRAINED SHORTEST PATH PROBLEM. 1 Applications and Modelling

EXERCISES SHORTEST PATHS: APPLICATIONS, OPTIMIZATION, VARIATIONS, AND SOLVING THE CONSTRAINED SHORTEST PATH PROBLEM. 1 Applications and Modelling SHORTEST PATHS: APPLICATIONS, OPTIMIZATION, VARIATIONS, AND SOLVING THE CONSTRAINED SHORTEST PATH PROBLEM EXERCISES Prepared by Natashia Boland 1 and Irina Dumitrescu 2 1 Applications and Modelling 1.1

More information

Single Source Shortest Path

Single Source Shortest Path Single Source Shortest Path A directed graph G = (V, E) and a pair of nodes s, d is given. The edges have a real-valued weight W i. This time we are looking for the weight and the shortest path from s

More information

Total Points: 60. Duration: 1hr

Total Points: 60. Duration: 1hr CS800 : Algorithms Fall 201 Nov 22, 201 Quiz 2 Practice Total Points: 0. Duration: 1hr 1. (,10) points Binary Heap. (a) The following is a sequence of elements presented to you (in order from left to right):

More information

Design and Analysis of Algorithms - - Assessment

Design and Analysis of Algorithms - - Assessment X Courses» Design and Analysis of Algorithms Week 1 Quiz 1) In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise.

More information

Week 5. 1 Analysing BFS. 2 Depth-first search. 3 Analysing DFS. 4 Dags and topological sorting. 5 Detecting cycles. CS 270 Algorithms.

Week 5. 1 Analysing BFS. 2 Depth-first search. 3 Analysing DFS. 4 Dags and topological sorting. 5 Detecting cycles. CS 270 Algorithms. 1 2 Week 5 3 4 5 General remarks We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week

More information

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

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies: UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.

More information

Konigsberg Bridge Problem

Konigsberg Bridge Problem Graphs Konigsberg Bridge Problem c C d g A Kneiphof e D a B b f c A C d e g D a b f B Euler s Graph Degree of a vertex: the number of edges incident to it Euler showed that there is a walk starting at

More information

Pred 8 1. Dist. Pred

Pred 8 1. Dist. Pred CS Graph Algorithms, Page Shortest Path Problem Task: given a graph G, find the shortest path from a vertex u to a vertex v. ffl If all edges are of the same length, then BFS will do. ffl But some times

More information

Reference Sheet for CO142.2 Discrete Mathematics II

Reference Sheet for CO142.2 Discrete Mathematics II Reference Sheet for CO14. Discrete Mathematics II Spring 017 1 Graphs Defintions 1. Graph: set of N nodes and A arcs such that each a A is associated with an unordered pair of nodes.. Simple graph: no

More information

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207. MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/ Graphs and Trees http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/l2-graphsandtrees.pdf

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

More information

Graph Algorithms (part 3 of CSC 282),

Graph Algorithms (part 3 of CSC 282), Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/10cs8 1 Schedule Homework is due Thursday, Oct 1. The QUIZ will be on Tuesday, Oct. 6. List of algorithms covered in the

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

More information

Exam 3 Practice Problems

Exam 3 Practice Problems Exam 3 Practice Problems HONOR CODE: You are allowed to work in groups on these problems, and also to talk to the TAs (the TAs have not seen these problems before and they do not know the solutions but

More information

CMSC 451: Lecture 10 Dynamic Programming: Weighted Interval Scheduling Tuesday, Oct 3, 2017

CMSC 451: Lecture 10 Dynamic Programming: Weighted Interval Scheduling Tuesday, Oct 3, 2017 CMSC 45 CMSC 45: Lecture Dynamic Programming: Weighted Interval Scheduling Tuesday, Oct, Reading: Section. in KT. Dynamic Programming: In this lecture we begin our coverage of an important algorithm design

More information

Robert Collins CSE586 CSE 586, Spring 2009 Advanced Computer Vision

Robert Collins CSE586 CSE 586, Spring 2009 Advanced Computer Vision CSE 586, Spring 2009 Advanced Computer Vision Dynamic Programming Decision Sequences Let D be a decision sequence {d1,d2,,dn}. (e.g. in a shortest path problem, d1 is the start node, d2 is the second node

More information

Algorithms IV. Dynamic Programming. Guoqiang Li. School of Software, Shanghai Jiao Tong University

Algorithms IV. Dynamic Programming. Guoqiang Li. School of Software, Shanghai Jiao Tong University Algorithms IV Dynamic Programming Guoqiang Li School of Software, Shanghai Jiao Tong University Dynamic Programming Shortest Paths in Dags, Revisited Shortest Paths in Dags, Revisited The special distinguishing

More information

Recitation 12. Dynamic Programming Announcements. SegmentLab has been released and is due Apr 14.

Recitation 12. Dynamic Programming Announcements. SegmentLab has been released and is due Apr 14. Recitation 12 Dynamic Programming 12.1 Announcements SegmentLab has been released and is due Apr 14. 73 74 RECITATION 12. DYNAMIC PROGRAMMING 12.2 Matrix Chain Product Definition 12.1. In the matrix chain

More information

Graph Algorithms (part 3 of CSC 282),

Graph Algorithms (part 3 of CSC 282), Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/11cs8 Homework problem sessions are in CSB 601, 6:1-7:1pm on Oct. (Wednesday), Oct. 1 (Wednesday), and on Oct. 19 (Wednesday);

More information

Lecture 15: Matching Problems. (Reading: AM&O Chapter 12)

Lecture 15: Matching Problems. (Reading: AM&O Chapter 12) Lecture 15: Matching Problems (Reading: AM& Chapter 12) The General Matching Problem Given: Undirected graph G = (N, A), with costs c ij on each arc (i, j) of G. Find: A matching (set of disjoint arcs)

More information

4 Linear Programming (LP) E. Amaldi -- Foundations of Operations Research -- Politecnico di Milano 1

4 Linear Programming (LP) E. Amaldi -- Foundations of Operations Research -- Politecnico di Milano 1 4 Linear Programming (LP) E. Amaldi -- Foundations of Operations Research -- Politecnico di Milano 1 Definition: A Linear Programming (LP) problem is an optimization problem: where min f () s.t. X n the

More information

LECTURES 3 and 4: Flows and Matchings

LECTURES 3 and 4: Flows and Matchings LECTURES 3 and 4: Flows and Matchings 1 Max Flow MAX FLOW (SP). Instance: Directed graph N = (V,A), two nodes s,t V, and capacities on the arcs c : A R +. A flow is a set of numbers on the arcs such that

More information

Shortest Path Problem

Shortest Path Problem Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths

More information

CMPSCI 311: Introduction to Algorithms Practice Final Exam

CMPSCI 311: Introduction to Algorithms Practice Final Exam CMPSCI 311: Introduction to Algorithms Practice Final Exam Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more detail including

More information

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number: Name: Entry number: There are 6 questions for a total of 75 points. 1. Consider functions f(n) = 10n2 n + 3 n and g(n) = n3 n. Answer the following: (a) ( 1 / 2 point) State true or false: f(n) is O(g(n)).

More information

Lecture 9 Graph Traversal

Lecture 9 Graph Traversal Lecture 9 Graph Traversal Euiseong Seo (euiseong@skku.edu) SWE00: Principles in Programming Spring 0 Euiseong Seo (euiseong@skku.edu) Need for Graphs One of unifying themes of computer science Closely

More information

Branch-and-bound: an example

Branch-and-bound: an example Branch-and-bound: an example Giovanni Righini Università degli Studi di Milano Operations Research Complements The Linear Ordering Problem The Linear Ordering Problem (LOP) is an N P-hard combinatorial

More information

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

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

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 1, Winter 201 Design and Analysis of Algorithms Lecture 7: Bellman-Ford, SPs in DAGs, PQs Class URL: http://vlsicad.ucsd.edu/courses/cse1-w1/ Lec. Added after class Figure.: Single-Edge Extensions

More information

Chapter 3 Trees. Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path.

Chapter 3 Trees. Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path. Chapter 3 Trees Section 3. Fundamental Properties of Trees Suppose your city is planning to construct a rapid rail system. They want to construct the most economical system possible that will meet the

More information

CS781 Lecture 2 January 13, Graph Traversals, Search, and Ordering

CS781 Lecture 2 January 13, Graph Traversals, Search, and Ordering CS781 Lecture 2 January 13, 2010 Graph Traversals, Search, and Ordering Review of Lecture 1 Notions of Algorithm Scalability Worst-Case and Average-Case Analysis Asymptotic Growth Rates: Big-Oh Prototypical

More information

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G. MAD 3105 Spring 2006 Solutions for Review for Test 2 1. Define a graph G with V (G) = {a, b, c, d, e}, E(G) = {r, s, t, u, v, w, x, y, z} and γ, the function defining the edges, is given by the table ɛ

More information

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

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies Graph Chapter 9 Outline Introduction Definitions and Basic Terminologies Representations of Graphs Graph Traversals Breadth first traversal Depth first traversal Applications Single source shortest path

More information

(Refer Slide Time: 05:25)

(Refer Slide Time: 05:25) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering IIT Delhi Lecture 30 Applications of DFS in Directed Graphs Today we are going to look at more applications

More information

Chordal Graphs: Theory and Algorithms

Chordal Graphs: Theory and Algorithms Chordal Graphs: Theory and Algorithms 1 Chordal graphs Chordal graph : Every cycle of four or more vertices has a chord in it, i.e. there is an edge between two non consecutive vertices of the cycle. Also

More information

Dynamic-Programming algorithms for shortest path problems: Bellman-Ford (for singlesource) and Floyd-Warshall (for all-pairs).

Dynamic-Programming algorithms for shortest path problems: Bellman-Ford (for singlesource) and Floyd-Warshall (for all-pairs). Lecture 13 Graph Algorithms I 13.1 Overview This is the first of several lectures on graph algorithms. We will see how simple algorithms like depth-first-search can be used in clever ways (for a problem

More information

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq

More information

CSI 604 Elementary Graph Algorithms

CSI 604 Elementary Graph Algorithms CSI 604 Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. (Second edition) 1 / 25 Graphs: Basic Definitions Undirected Graph G(V, E): V is set of nodes (or vertices) and E is the

More information

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conquer Algorithm Design Technique Decrease-and-Conquer This algorithm design technique is based on exploiting a relationship between

More information

2. CONNECTIVITY Connectivity

2. CONNECTIVITY Connectivity 2. CONNECTIVITY 70 2. Connectivity 2.1. Connectivity. Definition 2.1.1. (1) A path in a graph G = (V, E) is a sequence of vertices v 0, v 1, v 2,..., v n such that {v i 1, v i } is an edge of G for i =

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer CSC 8301- Design and Analysis of Algorithms Lecture 5 Decrease and Conuer Algorithm Design Techniue Decrease-and-Conuer This algorithm design techniue is based on exploiting a relationship between a solution

More information

Reverse-Engineering Database An IDA-Pro Plug-in. Graph Similarity. 1. Introduction

Reverse-Engineering Database An IDA-Pro Plug-in. Graph Similarity. 1. Introduction Reverse-Engineering Database An IDA-Pro Plug-in Graph Similarity 1. Introduction Functions can be viewed as control-flow-graphs 1 using IDA. These directed graphs contain nodes, and edges between them,

More information

Problem Set 6 Solutions

Problem Set 6 Solutions # # Introduction to Algorithms November 14, 003 Massachusetts Institute of Technology 6.046J/18.410J Professors Shafi Goldwasser and Silvio Micali Handout 4 Problem Set 6 Solutions Problem 6-1. ycles (a)

More information

Outline. Graphs. Divide and Conquer.

Outline. Graphs. Divide and Conquer. GRAPHS COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges books. Outline Graphs.

More information

Network optimization: An overview

Network optimization: An overview Network optimization: An overview Mathias Johanson Alkit Communications 1 Introduction Various kinds of network optimization problems appear in many fields of work, including telecommunication systems,

More information

Solutions to Problem Set 3

Solutions to Problem Set 3 G22.3250-001 Honors Analysis of Algorithms November 3, 2016 Solutions to Problem Set 3 Name: Daniel Wichs (TA) Due: October 27, 2008 Problem 1 Given a tree with (possibly negative) weights assigned to

More information

CSci 231 Final Review

CSci 231 Final Review CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.

More information

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 3 Graphs CLRS 12-13 Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 25 3.4 Testing Bipartiteness Bipartite Graphs Def. An undirected graph G = (V, E) is bipartite

More information

Goals! CSE 417: Algorithms and Computational Complexity!

Goals! CSE 417: Algorithms and Computational Complexity! Goals! CSE : Algorithms and Computational Complexity! Graphs: defns, examples, utility, terminology! Representation: input, internal! Traversal: Breadth- & Depth-first search! Three Algorithms:!!Connected

More information

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8 Fundamental Algorithms CSCI-GA.70-00/Summer 206 Solution to Homework 8 Problem (CLRS 23.-6). ( point) Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique

More information

CS173 Longest Increasing Substrings. Tandy Warnow

CS173 Longest Increasing Substrings. Tandy Warnow CS173 Longest Increasing Substrings Tandy Warnow CS 173 Longest Increasing Substrings Tandy Warnow Today s material The Longest Increasing Subsequence problem DP algorithm for finding a longest increasing

More information

Rollout Algorithms for Discrete Optimization: A Survey

Rollout Algorithms for Discrete Optimization: A Survey Rollout Algorithms for Discrete Optimization: A Survey by Dimitri P. Bertsekas Massachusetts Institute of Technology Cambridge, MA 02139 dimitrib@mit.edu August 2010 Abstract This chapter discusses rollout

More information

Homework Assignment #3. 1 (5 pts) Demonstrate how mergesort works when sorting the following list of numbers:

Homework Assignment #3. 1 (5 pts) Demonstrate how mergesort works when sorting the following list of numbers: CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 1 (5 pts) Demonstrate how mergesort works when sorting the following list of numbers: 6 1 4 2 3 8 7 5 2 Given the following array (list),

More information

Algorithms for Data Science

Algorithms for Data Science Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Shortest paths in weighted graphs (Bellman-Ford, Floyd-Warshall) Outline 1 Shortest paths in graphs with

More information

A4B33ALG 2015/10 ALG 10. Dynamic programming. abbreviation: DP. Sources, overviews, examples see.

A4B33ALG 2015/10 ALG 10. Dynamic programming. abbreviation: DP. Sources, overviews, examples see. ALG 0 Dynamic programming abbreviation: DP Sources, overviews, examples see https://cw.fel.cvut.cz/wiki/courses/ae4balg/links 0 Dynamic programming DP is a general strategy applicable to many different

More information

Algorithm Design (8) Graph Algorithms 1/2

Algorithm Design (8) Graph Algorithms 1/2 Graph Algorithm Design (8) Graph Algorithms / Graph:, : A finite set of vertices (or nodes) : A finite set of edges (or arcs or branches) each of which connect two vertices Takashi Chikayama School of

More information

Lecture 3: Totally Unimodularity and Network Flows

Lecture 3: Totally Unimodularity and Network Flows Lecture 3: Totally Unimodularity and Network Flows (3 units) Outline Properties of Easy Problems Totally Unimodular Matrix Minimum Cost Network Flows Dijkstra Algorithm for Shortest Path Problem Ford-Fulkerson

More information

CS 3410 Ch 14 Graphs and Paths

CS 3410 Ch 14 Graphs and Paths CS 3410 Ch 14 Graphs and Paths Sections 14.1-14.3 Pages 527-552 Exercises 1,2,5,7-9 14.1 Definitions 1. A vertex (node) and an edge are the basic building blocks of a graph. Two vertices, (, ) may be connected

More information

Sample Solutions to Homework #4

Sample Solutions to Homework #4 National Taiwan University Handout #25 Department of Electrical Engineering January 02, 207 Algorithms, Fall 206 TA: Zhi-Wen Lin and Yen-Chun Liu Sample Solutions to Homework #4. (0) (a) Both of the answers

More information

Centrality Measures. Computing Closeness and Betweennes. Andrea Marino. Pisa, February PhD Course on Graph Mining Algorithms, Università di Pisa

Centrality Measures. Computing Closeness and Betweennes. Andrea Marino. Pisa, February PhD Course on Graph Mining Algorithms, Università di Pisa Computing Closeness and Betweennes PhD Course on Graph Mining Algorithms, Università di Pisa Pisa, February 2018 Centrality measures The problem of identifying the most central nodes in a network is a

More information

ICS 351: Today's plan. netmask exercises network and subnetwork design dynamic routing RIP distance-vector routing

ICS 351: Today's plan. netmask exercises network and subnetwork design dynamic routing RIP distance-vector routing ICS 351: Today's plan netmask exercises network and subnetwork design dynamic routing RIP distance-vector routing Netmask exercises how many bits in this netmask: 255.128.0.0 using this netmask and the

More information

CSC 373 Lecture # 3 Instructor: Milad Eftekhar

CSC 373 Lecture # 3 Instructor: Milad Eftekhar Huffman encoding: Assume a context is available (a document, a signal, etc.). These contexts are formed by some symbols (words in a document, discrete samples from a signal, etc). Each symbols s i is occurred

More information

Department of Mathematics Oleg Burdakov of 30 October Consider the following linear programming problem (LP):

Department of Mathematics Oleg Burdakov of 30 October Consider the following linear programming problem (LP): Linköping University Optimization TAOP3(0) Department of Mathematics Examination Oleg Burdakov of 30 October 03 Assignment Consider the following linear programming problem (LP): max z = x + x s.t. x x

More information

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

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Lecture 4: Primal Dual Matching Algorithm and Non-Bipartite Matching. 1 Primal/Dual Algorithm for weighted matchings in Bipartite Graphs

Lecture 4: Primal Dual Matching Algorithm and Non-Bipartite Matching. 1 Primal/Dual Algorithm for weighted matchings in Bipartite Graphs CMPUT 675: Topics in Algorithms and Combinatorial Optimization (Fall 009) Lecture 4: Primal Dual Matching Algorithm and Non-Bipartite Matching Lecturer: Mohammad R. Salavatipour Date: Sept 15 and 17, 009

More information