Spanning Tree. Preview. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree 10/17/2017.

Similar documents
Preview. Graph. Graph. Graph. Graph Representation. Graph Representation 12/3/2018. Graph Graph Representation Graph Search Algorithms

Minimum Spanning Trees

Minimum Spanning Trees

COMP108 Algorithmic Foundations

Lecture 20: Minimum Spanning Trees (CLRS 23)

A general N-dimensional vector consists of N values. They can be arranged as a column or a row and can be real or complex.

Linear Algebra Existence of the determinant. Expansion according to a row.

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

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

Convergence Theorems for Two Iterative Methods. A stationary iterative method for solving the linear system: (1.1)

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

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

Last time: introduced our first computational model the DFA.

Lecture II: Minimium Spanning Tree Algorithms

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

4.1 Interval Scheduling. Chapter 4. Greedy Algorithms. Interval Scheduling: Greedy Algorithms. Interval Scheduling. Interval scheduling.

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

ON THE COMPLEXITY OF K-STEP AND K-HOP DOMINATING SETS IN GRAPHS

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

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list.

Walk Like a Mathematician Learning Task:

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

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

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

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

Minimum Spanning Trees (CLRS 23)

ERDOS-SMARANDACHE NUMBERS. Sabin Tabirca* Tatiana Tabirca**

Shortest Paths in Graphs. Paths in graphs. Shortest paths CS 445. Alon Efrat Slides courtesy of Erik Demaine and Carola Wenk

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

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

Ch 1.2: Solutions of Some Differential Equations

Lucas Test is based on Euler s theorem which states that if n is any integer and a is coprime to n, then a φ(n) 1modn.

CONTINUITY AND DIFFERENTIABILITY

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

Copyright 2000, Kevin Wayne 1

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

Week 3: Connected Subgraphs

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, *

INTEGRALS. Chapter 7. d dx. 7.1 Overview Let d dx F (x) = f (x). Then, we write f ( x)

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

Weighted Graphs. Weighted graphs may be either directed or undirected.

Section 3: Antiderivatives of Formulas

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

Section 5.1/5.2: Areas and Distances the Definite Integral

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

(Minimum) Spanning Trees

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

8. Linear Contracts under Risk Neutrality

Spanning Trees. BFS, DFS spanning tree Minimum spanning tree. March 28, 2018 Cinda Heeren / Geoffrey Tien 1

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

Lecture 11 Waves in Periodic Potentials Today: Questions you should be able to address after today s lecture:

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

(A) the function is an eigenfunction with eigenvalue Physical Chemistry (I) First Quiz

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

DFA (Deterministic Finite Automata) q a

TOPIC 5: INTEGRATION

Fundamentals of Continuum Mechanics. Seoul National University Graphics & Media Lab

Review - Probabilistic Classification

1.9 Cartesian Tensors

Single Source Shortest Paths (with Positive Weights)

Filter Design Techniques

Weighted Matching and Linear Programming

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

Strongly Connected Components

Garnir Polynomial and their Properties

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

Multi-Section Coupled Line Couplers

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

Basic Polyhedral theory

The Equitable Dominating Graph

1 Introduction to Modulo 7 Arithmetic

Minimum Spanning Trees (CLRS 23)

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

Rank One Update And the Google Matrix by Al Bernstein Signal Science, LLC

13. Binary tree, height 4, eight terminal vertices 14. Full binary tree, seven vertices v 7 v13. v 19

, between the vertical lines x a and x b. Given a demand curve, having price as a function of quantity, p f (x) at height k is the curve f ( x,

5/1/2018. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees

Constructive Geometric Constraint Solving

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

CSE 417, Winter Greedy Algorithms 1/27/2012. Chapter 4. Ben Birnbaum Widad Machmouchi. 4.1 Interval Scheduling.

This Week. Computer Graphics. Introduction. Introduction. Graphics Maths by Example. Graphics Maths by Example

CIVL 8/ D Boundary Value Problems - Rectangular Elements 1/7

ME 522 PRINCIPLES OF ROBOTICS. FIRST MIDTERM EXAMINATION April 19, M. Kemal Özgören

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

Present state Next state Q + M N

Analysis of Algorithms - Elementary graphs algorithms -

Problem solving by search

4.5 Minimum Spanning Tree. Chapter 4. Greedy Algorithms. Minimum Spanning Tree. Motivating application

10. EXTENDING TRACTABILITY

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

10/7/14. Mixture Models. Comp 135 Introduction to Machine Learning and Data Mining. Maximum likelihood estimation. Mixture of Normals in 1D

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

Dennis Bricker, 2001 Dept of Industrial Engineering The University of Iowa. MDP: Taxi page 1

Partially Observable Systems. 1 Partially Observable Markov Decision Process (POMDP) Formalism

CSI35 Chapter 11 Review

Analysis of Algorithms - Elementary graphs algorithms -

b.) v d =? Example 2 l = 50 m, D = 1.0 mm, E = 6 V, " = 1.72 #10 $8 % & m, and r = 0.5 % a.) R =? c.) V ab =? a.) R eq =?

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016

In which direction do compass needles always align? Why?

Transcription:

0//0 Prvw Spnnng Tr Spnnng Tr Mnmum Spnnng Tr Kruskl s Algorthm Prm s Algorthm Corrctnss of Kruskl s Algorthm A spnnng tr T of connctd, undrctd grph G s tr composd of ll th vrtcs nd som (or prhps ll) of th dgs of G. Informlly, spnnng tr of G s slcton of dgs of G tht form tr spnnng vry vrtx. Evry vrtx ls n th tr, but no cycls (or loops) r formd. COSC 0 - Sprng 0 COSC 0 - Sprng 0 Mnmum Spnnng Tr A spnnng tr tht hs mnmum totl wght s clld mnmum spnnng tr for th grph. Tchnclly t s mnmum-wght spnnng tr. If ll dgs hv th sm wght, brdth-frst srch or dpth-frst srch wll yld mnmum spnnng trs. For th rst of ths dscusson, w ssum th dgs hv wghts ssoctd wth thm. Mnmum Spnnng Tr Mnmum-cost spnnng trs hv mny pplctons. Buldng cbl ntworks tht jon n loctons wth mnmum cost. Buldng rod ntwork tht jons n cts wth mnmum cost. Obtnng n ndpndnt st of crcut qutons for n lctrcl ntwork. In pttrn rcognton mnml spnnng trs cn b usd to fnd nosy pxls. COSC 0 - Sprng 0 COSC 0 - Sprng 0 Mnmum Spnnng Tr Consdr ths grph. It hs 0 spnnng trs. Som r: Thr r two mnmumcost spnnng trs, ch wth cost of : COSC 0 - Sprng 0 Mnmum Spnnng Tr Brut Forc opton:. For ll possbl spnnng trs. Clcult th sum of th dg wghts. Kp trck of th tr wth th mnmum wght. Stp () rqurs N- tm, snc ch tr wll hv xctly N- dgs. If thr r M spnnng trs, thn th totl cost wll O(MN). Consdr complt grph wth N(N-) dgs. How bg cn M b? COSC 0 - Sprng 0

0//0 Brut Forc MST For complt grph, t hs bn shown tht thr r N N- possbl spnnng trs! Altrntvly, gvn N tms, you cn buld N N- dstnct trs to connct ths tms. Input: connctd undrctd grph G = (V, E) whr for ch dg (u, v) E, w hv wght w(u, v) Output: Fnd n cyclc subst T E tht conncts ll of th vrtcs nd whos totl wght s mnmzd. COSC 0 - Sprng 0 COSC 0 - Sprng 0 Th Mnmum Spnnng Tr lgorthms w wll look t r grdy lgorthms. Grdy lgorthms lwys mk chocs tht look bst t th momnt. Thy mk loclly optml chocs n th hop tht ths chocs wll ld to globlly optml soluton. It s mportnt to not tht grdy lgorthms do not lwys yld optml solutons. COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s lgorthm Kruskl s lgorthm s grdy lgorthm, bcus t ch stp t dds to th forst n dg of lst possbl wght. Spcfclly, th lgorthm chooss th lowst wght dg tht jons two dsconnctd trs nto sngl tr. COSC 0 - Sprng 0 0 Kruskl s Algorthm Kruskl (G, w) { A = Strt wth forst whr thr r V trs Sort th dgs of E by non-dcrsng wght w. for ch dg (u, v) E, n ordr by ncrsng wght { If u nd v do not blong to th sm tr { A = A {(u, v)} Mk two trs connct wth dg (u, v). } } } Kruskl s Algorthm 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 0 5

0//0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0

0//0 Kruskl s Algorthm Kruskl s Algorthm 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 Kruskl s Algorthm (Prm s Algorthm) 0 Prm s lgorthm hs th proprty tht th dgs n th st E lwys form sngl tr. It strts wth ny nod nd xpnds untl th tr spns ll th vrtcs n V. At ch stp, lght dg connctng vrtx n A to vrtx n V-A s ddd to th tr. Ths strtgy s grdy snc n dg wth mnmum mount possbl to th tr s wght s chosn to buld tr. Th ky to mplmntng Prm s lgorthm s to mk t sy to slct nw dg to b ddd to th tr formd by th dgs n A. COSC 0 - Sprng 0 COSC 0 - Sprng 0 0 (Prm s Algorthm) Implmntton of Prm s Algorthm Ech nod u V hs two lmnts: u.ky nd u.prnt. u.ky s usd to fnd out th mnmum possbl conncton to th nod (usng prorty quu, Q) u.prnt s usd for buldng tr. (Prm s Algorthm) Prm(V, E) { Intlz: V nw = {r}, whr r s n rbtrry nod r V, E nw = {} Rpt untl V nw = V { Choos n dg {u, v} wth mnml wght such tht u V nw nd v V - V nw // If thr r multpl dgs wth th sm wght, // ny of thm my b pckd Add v to V nw, nd {(u, v)} to E nw } rturn V nw nd E nw dscrb mnml spnnng tr } COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 COSC 0 - Sprng 0 50 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 5 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 5

0//0 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 55 COSC 0 - Sprng 0 5 (Prm s Algorthm) (Prm s Algorthm) 0 0 COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 5 (Prm s Algorthm) (Prm s Algorthm) Runnng tm of Prm s Algorthm 0 Intlzton nd buldng Hp: O(V) Extrct Mn s O(log V), nd thr r V tms for xtrct mn: O(V log V) Th for loop xcuts O(E) tms, nvstgtng whthr or not n Q tk constnt tm by kp bt mtrx for Q: O(E) Dcrsng ky v.ky = w(u, v) tks O(log V) for djustng prorty quu: O(E log V) COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 0 0

0//0 Prm s lgorthm wth n Adjcncy Mtrx A cbl compny wnt to connct fv vllgs to thr ntwork whch currntly xtnds to th mrkt town of Avnford. Wht s th mnmum lngth of cbl ndd? Avnford Brnlgh 5 Fngly 5 Cornwll Donstr Prm s lgorthm wth n Adjcncy Mtrx Not, ths xmpl hs outgong dgs on th columns nd ncomng on th rows, so t s th trnspos of djcncy mtrx mntond n clss. Actully, t s n undrctd, so A T = A. A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - Edn COSC 0 - Sprng 0 COSC 0 - Sprng 0 Strt t vrtx A. Lbl column A. Dlt row A Slct th smllst ntry n column A (AB, lngth ) Lbl column B Dlt row B Slct th smllst uncovrd ntry n thr column A or column B (AE, lngth ) Avnford Brnlgh A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - Brnlgh Avnford Edn A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - COSC 0 - Sprng 0 COSC 0 - Sprng 0 Lbl column E Dlt row E Slct th smllst uncovrd ntry n thr column A, B or E (ED, lngth ) Lbl column D Dlt row D Slct th smllst uncovrd ntry n thr column A, B, D or E (DC, lngth ) Brnlgh Avnford Edn Donstr A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - Brnlgh Avnford Edn Cornwll Donstr A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - COSC 0 - Sprng 0 5 COSC 0 - Sprng 0

0//0 Lbl column C 5 Dlt row C Slct th smllst uncovrd ntry n thr column A, B, D, E or C (EF, lngth 5) Avnford Brnlgh Fngly 5 Cornwll Donstr 5 A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - FINALLY Lbl column F Dlt row F Brnlgh Avnford Cornwll Fngly Donstr 5 5 A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - Edn Edn COSC 0 - Sprng 0 COSC 0 - Sprng 0 FINALLY Avnford Lbl column F Dlt row F Brnlgh Edn Fngly 5 Cornwll Donstr 5 A - - - B - 5 - - C - 5 - - D - - - E - - - 5 F 5 - Th spnnng tr s shown n th dgrm Lngth + + + + 5 = Km COSC 0 - Sprng 0 Prctc G B. Fnd th brdth-frst spnnng tr nd dpth-frst spnnng tr of th grph G A shown bov.. For th grph G B shown bov, trc th xcuton of Prm's lgorthm s t fnds th mnmum-cost spnnng tr of th grph strtng from vrtx. COSC 0 - Sprng 0 0 Corrctnss of Mnmum Spnnng tr Corrctnss of MST Algorthm Lt G = (V, E) s undrctd wghtd grph. Kruskul s lgorthm strts wth V forsts nd ultmtly crts mnmum spnnng tr T whch ncluds ll vrtcs n V. Prm s lgorthm strts wth tr wth sngl nod nd vntully bulds mnmum spnnng tr. Both lgorthms us grdy mthods to fnd n dg (u, v) whch s loclly optml. Corrctnss of Mnmum Spnnng tr Algorthm mngs st of dgs A whch s subst of mnmum spnnng tr. For ch trton lgorthm pck n dg (u, v) such tht A { (u, v)} s lso subst of mnmum spnnng tr. W cll such n dg sf dg for A. A cut (S, V S) of undrctd grph G = (V, E) s prtton of V. COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 Corrctnss of Mnmum Spnnng tr Corrctnss of Mnmum Spnnng tr W sy n dg (u, v) E crosss th cut (S, V S) f on vrtx blongs to S nd othr blongs to V S. W sy cut rspcts st A of dgs f no dgs n A cross th cut. An dg (u, v) s lght dg crossng cut f ts wght w (u, v) s th mnmum of ny dg crossng th cut 0 Lght dg = (c, d) COSC 0 - Sprng 0 COSC 0 - Sprng 0 Corrctnss of Mnmum Spnnng tr Corrctnss of Mnmum Spnnng tr Thorm) Lt G = (V, E) b connctd undrctd grph wth wght w(u, v) for ch (u, v) E. Lt A E whch s prt of mnmum spnnng tr for G. Lt (S, V S) s ny cut of G rspct A. Lt (u, v) b lght dg crossng (S, V S). Thn dg (u, v) s sf for A. Prov) By Contrdcton Lt T b mnmum spnnng tr ncludng A but not lght dg (u, v). Lt s try to buld nothr mnmum spnnng tr T whch ncluds A (u, v) by modfyng T. Snc T s mnmum spnnng tr, thr should b pth from u to v. COSC 0 - Sprng 0 5 COSC 0 - Sprng 0 Corrctnss of Mnmum Spnnng tr Corrctnss of Mnmum Spnnng tr x x u u y v y v Snc u nd v r on oppost sd of cut (S, V S), Thr must t ls on dg (x, y) n T on th pth clos th cut. And lso (x, y) s not n A snc th cut rspct A. If w rmov dg (x, y) from th T. thr r two componnts Addng (u, v) crt nw tr T Snc (u, v) s lght wght dg, w(u, v) w (x, y) Totl wght of nw tr T s w(t ) = w(t) w(x,y) + w(u, v) w(t) If (u, v) s unqu lght wght dg, W(T ) < W(T) contrdcton W cn conclud wth tht dg (u, v) s sf for A. COSC 0 - Sprng 0 COSC 0 - Sprng 0

0//0 Corrctnss of Mnmum Spnnng tr Thorm) Prov Mnmum spnnng tr lgorthm crts mnmum spnnng tr. Prov) Kruskul s nd Prm s lgorthms choos n dg (u, v) tht s sf for A for ch trton. And wth lmm MST lgorthm must crt MST. COSC 0 - Sprng 0