TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.

Slides:



Advertisements
Similar presentations
Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.
Advertisements

 2004 SDU Lecture9- Single-Source Shortest Paths 1.Related Notions and Variants of Shortest Paths Problems 2.Properties of Shortest Paths and Relaxation.
Combinatorial Algorithms
Lecture 3: Greedy Method Greedy Matching Coin Changing Minimum Spanning Tree Fractional Knapsack Dijkstra's Single-Source Shortest-Path.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Chapter 23 Minimum Spanning Trees
1 Spanning Trees Lecture 20 CS2110 – Spring
Applied Discrete Mathematics Week 12: Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
The Shortest Path Problem
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Dijkstra's algorithm.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
GRAPH Learning Outcomes Students should be able to:
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
Analysis of Algorithms
1  Introduction to Graph Data Structure  Applications  Graph Searching  Minimum Spanning Trees  Shortest Path problems.
COSC 3101NJ. Elder Assignment 2 Remarking Assignment 2 Marks y = 0.995x R 2 = Old Mark New Mark.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
5.4 Shortest-path problem  Let G=(V,E,w) be a weighted connected simple graph, w is a function from edges set E to position real numbers set. We denoted.
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
COSC 2007 Data Structures II Chapter 14 Graphs III.
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
© 2015 JW Ryder CSCI 203 Data Structures1. © 2015 JW Ryder CSCI 203 Data Structures2.
Prims’ spanning tree algorithm Given: connected graph (V, E) (sets of vertices and edges) V1= {an arbitrary node of V}; E1= {}; //inv: (V1, E1) is a tree,
All-Pairs Shortest Paths & Essential Subgraph 01/25/2005 Jinil Han.
1 Greedy Algorithms and MST Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Introduction to Algorithms Jiafen Liu Sept
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Minimum spanning trees (MST) Def: A spanning tree of a graph G is an acyclic subset of edges of G connecting all vertices in G. A sub-forest of G is an.
Introduction to Graph Theory
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
 Hamilton paths.  Definition 20: A Hamilton paths is a path that contains each vertex exactly once. A Hamilton circuit is a circuit that contains.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Minimum Spanning Trees
Greedy Technique.
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Short paths and spanning trees
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Graph Algorithm.
CSCE350 Algorithms and Data Structure
Spanning Trees.
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
ICS 353: Design and Analysis of Algorithms
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
CS 583 Analysis of Algorithms
Autumn 2015 Lecture 10 Minimum Spanning Trees
Minimum Spanning Tree Algorithms
Minimum Spanning Trees
Richard Anderson Lecture 10 Minimum Spanning Trees
Autumn 2016 Lecture 10 Minimum Spanning Trees
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Prims’ spanning tree algorithm
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Minimum Spanning Trees
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing Cost or Maximizing Benefits  Minimum Spanning Tree  Minimum cost for connecting all vertices  Single-Source Shortest Paths  Shortest Path between two vertices

Greedy Algorithms: Make the best choice now! Making choices in sequence such that  each individual choice is best  according to some limited “short-term” criterion,  that is not too expensive to evaluate  once a choice is made, it cannot be undone!  even if it becomes evident later that it was a poor choice Make progress by choosing an action that  incurs the minimum short-term cost,  in the hope that a lot of small short-term costs add up to small overall cost. Possible drawback:  actions with a small short-term cost may lead to a situation, where further large costs are unavoidable.

Optimization Problems Minimizing the total cost or Maximizing the total benefits  Analyze all possible outcomes and find the best, or  Make a series of choices whose overall effect is to achieve the optimal. Some optimization problems can be solved exactly by greedy algorithms  Minimum cost for connecting all vertices  Minimum Spanning Tree Algorithm  Shortest Path between two vertices  Single-Source Shortest Paths Algorithm

Minimum Spanning Tree A spanning tree for a connected, undirected graph, G=(V,E) is  a subgraph of G that is  an undirected tree and contains  all the vertices of G. In a weighted graph G=(V,E,W), the weight of a subgraph is  the sum of the weights of the edges in the subgraph. A minimum spanning tree for a weighted graph is  a spanning tree with the minimum weight.

Prim’s Minimum Spanning Tree Algorithm Select an arbitrary starting vertex, (the root) branches out from the tree constructed so far by  choosing an edge at each iteration  attach the edge to the tree  that edge has minimum weight among all edges that can be attached  add to the tree the vertex associated with the edge During the course of the algorithm, vertices are divided into three disjoint categories:  Tree vertices: in the tree constructed so far,  Fringe vertices: not in the tree, but adjacent to some vertex in the tree,  Unseen vertices: all others

The Algorithm in action, e.g.

Prim’s Minimum Spanning Trees: Outline

Properties of Minimum Spanning Trees Definition: Minimum spanning tree property  Let a connected,weighted graph G=(V,E,W) be given,and let T be any spanning tree of G.  Suppose that for every edge vw of G that is not in T,  if uv is added to T, then it creates a cycle  such that uv is a maximum-weight edge on that cycle.  The the tree T is said to have the minimum spanning tree property.

Properties of Minimum Spanning Trees … Lemma:  In a connected, weighted graph G = (V, E, W),  if T1 and T2 are two spanning trees that have the MST property,  then they have the same total weight. Theorem:  In a connected,weighted graph G=(V,E,W)  a tree T is a minimum spanning tree if and only if  T has the MST property.

Correctness of Prim’s MST Algorithm Lemma:  Let G = (V, E, W) be a connected, weighted graph with n = |V|;  let T k be the tree with k vertices constructed by Prim’s algorithm, for k = 1, …, n; and  let G k be the subgraph of G induced by the vertices of T k (i.e., uv is an edge in G k if it is an edge in G and both u and v are in T k ).  Then T k has the MST property in G k. Theorem:  Prim's algorithm outputs a minimum spanning tree.

Problem: Single-Source Shortest Paths Problem:  Finding a minimum-weight path between two specified vertices  It turns out that, in the worst case, it is no easier to find a minimum-weight path between a specified pair of nodes s and t than  it is to find minimum-weight path between s and every vertex reachable from s. (single-source shortest paths)

Shortest-Path Definition: shortest path  Let P be a nonempty path  in a weighted graph G=(V,E,W)  consisting of k edges xv 1,v 1 v 2,....v k-1 y (possibly v 1 =y).  The weight of P, denoted as W(P) is  the sum of the weights,W(xv 1 ),W(v 1 v 2 ),...W(v k-1 y).  If x=y, the empty path is considered to be a path from x to y. The weight of the empty path is zero.  If no path between x and y has weight less than W(P),  then P is called a shortest path,or minimum-weight path.

Properties of Shortest Paths Lemma: Shortest path property  In a weighted graph G,  suppose that a shortest path from x to z consist of  path P from x to y followed by  path Q from y to z.  Then P is a shortest path from x to y, and  Q is a shortest path form y to z.

Dijkstra’s Shortest-Path Algorithm  Greedy Algorithm  weights are nonnegative

The Algorithm in action, e.g.

Correctness of Dijkstra’s Shortest-Path Algorithm Theorem:  Let G=(V,E,W) be a weighted graph with nonnegative weights.  Let V' be a subset of V and  let s be a member of V'.  Assume that d(s,y) is the shortest distance in G from s to y, for each y  V'.  If edge yz is chosen to minimize d(s,y)+W(yz) over all edges with one vertex y in V' and one vertex z in V-V',  then the path consisting of a shortest path from s to y followed by the edge yz is a shortest path from s to z. Theorem:  Given a directed weighted graph G with a nonnegative weights and a source vertex s, Dijkstra's algorithm computes the shortest distance from s to each vertex of G that is reachable from s.