Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs

Similar documents
Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

CS 241 Analysis of Algorithms

CS 461, Lecture 17. Today s Outline. Example Run

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

1 Introduction to Modulo 7 Arithmetic

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Greedy Algorithms, Activity Selection, Minimum Spanning Trees Scribes: Logan Short (2015), Virginia Date: May 18, 2016

CSE 373. Graphs 1: Concepts, Depth/Breadth-First Search reading: Weiss Ch. 9. slides created by Marty Stepp

GREEDY TECHNIQUE. Greedy method vs. Dynamic programming method:

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

QUESTIONS BEGIN HERE!

CS61B Lecture #33. Administrivia: Autograder will run this evening. Today s Readings: Graph Structures: DSIJ, Chapter 12

COMP108 Algorithmic Foundations

10/30/12. Today. CS/ENGRD 2110 Object- Oriented Programming and Data Structures Fall 2012 Doug James. DFS algorithm. Reachability Algorithms

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

Minimum Spanning Trees

MAT3707. Tutorial letter 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/201/1/2017

CS200: Graphs. Graphs. Directed Graphs. Graphs/Networks Around Us. What can this represent? Sometimes we want to represent directionality:

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

QUESTIONS BEGIN HERE!

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

5/7/13. Part 10. Graphs. Theorem Theorem Graphs Describing Precedence. Outline. Theorem 10-1: The Handshaking Theorem

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

The University of Sydney MATH2969/2069. Graph Theory Tutorial 5 (Week 12) Solutions 2008

learning objectives learn what graphs are in mathematical terms learn how to represent graphs in computers learn about typical graph algorithms

16.unified Introduction to Computers and Programming. SOLUTIONS to Examination 4/30/04 9:05am - 10:00am

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1.

Outline. Binary Tree

Constructive Geometric Constraint Solving

CS September 2018

0.1. Exercise 1: the distances between four points in a graph

Announcements. Not graphs. These are Graphs. Applications of Graphs. Graph Definitions. Graphs & Graph Algorithms. A6 released today: Risk

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem)

A 4-state solution to the Firing Squad Synchronization Problem based on hybrid rule 60 and 102 cellular automata

Problem solving by search

N=4 L=4. Our first non-linear data structure! A graph G consists of two sets G = {V, E} A set of V vertices, or nodes f

Garnir Polynomial and their Properties

Trees as operads. Lecture A formalism of trees

Announcements. These are Graphs. This is not a Graph. Graph Definitions. Applications of Graphs. Graphs & Graph Algorithms

Present state Next state Q + M N

Seven-Segment Display Driver

Planar Upward Drawings

Lecture 20: Minimum Spanning Trees (CLRS 23)

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS

NP-Completeness. CS3230 (Algorithm) Traveling Salesperson Problem. What s the Big Deal? Given a Problem. What s the Big Deal? What s the Big Deal?

Chapter 18. Minimum Spanning Trees Minimum Spanning Trees. a d. a d. a d. f c

EE1000 Project 4 Digital Volt Meter

Section 10.4 Connectivity (up to paths and isomorphism, not including)

Depth First Search. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong

Computational Biology, Phylogenetic Trees. Consensus methods

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

Graph Contraction and Connectivity

Applications: The problem has several applications, for example, to compute periods of maximum net expenses for a design department.

Minimum Spanning Trees

Steinberg s Conjecture is false

Solutions to Homework 5

Organization. Dominators. Control-flow graphs 8/30/2010. Dominators, control-dependence. Dominator relation of CFGs

Multipoint Alternate Marking method for passive and hybrid performance monitoring

RAM Model. I/O Model. Real Machine Example: Nehalem : Algorithms in the Real World 4/9/13

Walk Like a Mathematician Learning Task:

Designing A Concrete Arch Bridge

Round 7: Graphs (part I)

ECE 407 Computer Aided Design for Electronic Systems. Circuit Modeling and Basic Graph Concepts/Algorithms. Instructor: Maria K. Michael.

CMSC 451: Lecture 2 Graph Basics Thursday, Aug 31, 2017

Similarity Search. The Binary Branch Distance. Nikolaus Augsten.

(2) If we multiplied a row of B by λ, then the value is also multiplied by λ(here lambda could be 0). namely

14 Shortest Paths (November 8)

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation

XML and Databases. Outline. Recall: Top-Down Evaluation of Simple Paths. Recall: Top-Down Evaluation of Simple Paths. Sebastian Maneth NICTA and UNSW

Numbering Boundary Nodes

1. Determine whether or not the following binary relations are equivalence relations. Be sure to justify your answers.

Graph Algorithms and Combinatorial Optimization Presenters: Benjamin Ferrell and K. Alex Mills May 7th, 2014

12. Traffic engineering

Yehuda Lindell Bar-Ilan University

Analysis for Balloon Modeling Structure based on Graph Theory

Solutions for HW11. Exercise 34. (a) Use the recurrence relation t(g) = t(g e) + t(g/e) to count the number of spanning trees of v 1

Using the Printable Sticker Function. Using the Edit Screen. Computer. Tablet. ScanNCutCanvas

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

(a) v 1. v a. v i. v s. (b)

Register Allocation. How to assign variables to finitely many registers? What to do when it can t be done? How to do so efficiently?

Properties of Hexagonal Tile local and XYZ-local Series

Register Allocation. Register Allocation. Principle Phases. Principle Phases. Example: Build. Spills 11/14/2012

Improving Union. Implementation. Union-by-size Code. Union-by-Size Find Analysis. Path Compression! Improving Find find(e)

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski

Lecture II: Minimium Spanning Tree Algorithms

Grade 7/8 Math Circles March 4/5, Graph Theory I- Solutions

Transcription:

Outlin Computr Sin 33 Computtion o Minimum-Cost Spnnin Trs Prim s Mik Joson Dprtmnt o Computr Sin Univrsity o Clry Ltur #34 Introution Min-Cost Spnnin Trs 3 Gnrl Constrution 4 5 Trmintion n Eiiny 6 Aitionl Commnts n Rrns Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 / 0 Introution Computtion o Min-Cost Spnnin Trs Min-Cost Spnnin Trs Costs o Spnnin Trs in Wiht Grphs Motivtion: Givn st o sits (rprsnt y vrtis o rph), onnt ths ll s hply s possil (usin onntions rprsnt y th s o wiht rph). Gols or Toy: prsnttion o th initions n to ormlly in prolm motivt y th ov prsnttion o n lorithm (Prim s ) or solvin th prolm Rll tht i G = (V, E) is onnt, unirt rph, thn spnnin tr o G is surph Ĝ = ( V, Ê) suh tht V = V (so Ĝ inlus ll th vrtis in G) Ĝ is tr Suppos now tht G = (V, E) is onnt wiht rph with wiht untion w : E N, n tht G = (V, E ) is spnnin tr o G Th ost o G, w(g ), is th sum o th wihts o th s in G, tht is, w(g ) = E w(). Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 3 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 4 / 0

Min-Cost Spnnin Trs Min-Cost Spnnin Trs Suppos G is wiht rph with wihts s shown low. Th ost o th ollowin spnnin tr, G = (V, E ), is 8. 5 3 3 4 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 5 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 6 / 0 Min-Cost Spnnin Trs Min-Cost Spnnin Trs Minimum-Cost Spnnin Trs Th ost o th ollowin spnnin tr, G = (V, E ), is 6. Suppos (G, w) is wiht rph. 5 A surph G o G is minimum-ost spnnin tr o (G, w) i th ollowin proprtis r stisi. G is spnnin tr o G. 3 w(g ) w(g ) or vry spnnin tr G o G. : In th prvious xmpl, G is lrly not minimum-ost spnnin tr, us G is spnnin tr o G suh tht w(g ) > w(g ). It n shown tht G is minimum-ost spnnin tr o (G, w). Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 7 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 8 / 0

Gnrl Constrution Builin Minimum-Cost Spnnin Tr Gnrl Constrution Builin Minimum-Cost Spnnin Tr To onstrut minimum-ost spnnin tr o G = (V, E): Strt with Ĝ = ( V, Ê), whr V V n Ê =. Not: Ĝ is surph o som minimum-ost spnnin tr o (G, w). Rptly vrtis (i nssry) n s nsurin tht Ĝ is still surph o minimum-ost spnnin tr s you o so. Continu oin this until V = V n Ê = V (so tht Ĝ is spnnin tr o Ĝ). Aitionl Nots: This n on in svrl irnt wys, n thr r t lst two irnt lorithms tht us this pproh to solv this prolm. Th lorithm to prsnt hr ins with V = {s} or som vrtx s V, n mks sur tht Ĝ is lwys tr. As rsult, this lorithm is struturlly vry similr to Dijkstr s to omput minimum-ost pths (whih w hv lry isuss in lss). Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 9 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 0 / 0 Spiition o Rquirmnts Dt Struturs Pr-Conition G = (V, E) is onnt rph with wiht untion w Post-Conition: π is untion π : V V {NIL} I Ê = {(π(v), v) v V n π(v) NIL} thn (V, Ê) is minimum-ost spnnin tr or G Th rph G = (V, E) n its wiht untion hv not n hn Th lorithm (to prsnt nxt) will us priority quu to stor inormtion out wihts o s tht r in onsir or inlusion Th priority quu will MinHp: th ntry with th smllst priority will t th top o th hp Eh no in th priority quu will stor vrtx in G n th wiht o n inint to this vrtx Th wiht will us s th vrtx s priority An rry-s rprsnttion o th priority quu will us A son rry will us to lot h ntry o th priority quu or ivn no in onstnt tim Not: Th t struturs will, thror, look vry muh lik th t struturs us y Dijkstr s lorithm. Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 / 0

Psuoo Psuoo, Continu MST-Prim(G, w, s) or v V o olour[v] = whit [v] = + π[v] = NIL n or Initiliz n mpty priority quu Q olour[s] = ry [s] = 0 s with priority 0 to Q whil (Q is not mpty) o (u, ) = xtrt-min(q) {Not: = [u]} or h v Aj[u] o i (olour[v] == whit) thn [v] = w((u, v)) olour[v] = ry; π[v] = u v with priority [v] to Q ls i (olour[v] == ry) thn Upt inormtion out v (Shown on nxt sli) n i n or olour[u] = lk n whil rturn π Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 3 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 4 / 0 Psuoo, Conlu Uptin Inormtion Aout v i (w((u, v)) < [v]) thn ol = [v] [v] = w((u, v)) π[v] = u Us Drs-Priority to rpl (v, ol) in Q with (v, [v]) n i Stp 7: Extrt-Min (rturns (, )) olor lk on! E. on MST (totl ost is 8): 0 π - Q: (mpty) {(π(), ), (π(), ), (π(), ), (π(), ), (π( ), ), (π(), )} = {(, ), (, ), (, ), (, ), (, ), (, )} Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 5 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 6 / 0

Trmintion n Eiiny Trmintion n Eiiny Trmintion n Eiiny Trmintion n Eiiny (ont.) Clim: I MST-Prim is xut on wiht unirt rph G = (V, E) thn th lorithm trmints tr prormin O(( V + E ) lo V ) stps in th worst s. Proo. This is virtully intil to th proo o th orrsponin rsult or Dijkstr s lorithm (to omput minimum-ost pths). Th numr o oprtions on th priority quu, n th numr o oprtions tht o not involv this t strutur, r h in Θ( V + E ) in th worst s (y th rumnt tht hs n ppli to th lst thr lorithms onsir). Proo (ontinu). Sin th siz o th priority quu nvr xs V n sin th only oprtions on th priority quu us r insrtions, rss o ky vlus, n xtrtions o th minimum (top priority) lmnt, th ost o h oprtion on th t strutur is in O(lo V ). It ollows immitly tht th totl numr o stps is in O(( V + E ) lo V ), s lim. O( V lo V + E ) usin Fioni hp (mortiz) Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 7 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 8 / 0 Aitionl Commnts n Rrns Aitionl Commnts Rrns Aitionl Commnts n Rrns On Gry s Prim s lorithm is n xmpl o ry lorithm: A lol optimiztion prolm (inin minimum-ost spnnin tr) is solv y mkin squn o lol ry hois (y xtnin tr with s whos wihts r s smll s possil). Provin orrtnss o ry lorithms is otn hllnin. In, ry huristis r otn inorrt. On th othr hn, whn thy r orrt, ry lorithms r rquntly simplr n mor iint thn othr lorithms or th sm omputtion. S CPSC 43 or mor out ry lorithms! Furthr Rin n Jv Co: Introution to s, Chptr 3 Chptr 3 inlus Prim s lorithm lon with nothr ry lorithm or this prolm (Kruskl s lorithm). Dt Struturs & s in Jv, Chptr 4 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 9 / 0 Mik Joson (Univrsity o Clry) Computr Sin 33 Ltur #34 0 / 0