Minimum Spanning Trees

Similar documents
Minimum Spanning Trees

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

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

Lecture 20: Minimum Spanning Trees (CLRS 23)

COMP108 Algorithmic Foundations

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.

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

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

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

(Minimum) Spanning Trees

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

Lecture II: Minimium Spanning Tree Algorithms

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

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

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

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

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

Copyright 2000, Kevin Wayne 1

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

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

Minimum Spanning Trees (CLRS 23)

Ch 1.2: Solutions of Some Differential Equations

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

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

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

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

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

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

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

Single Source Shortest Paths (with Positive Weights)

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

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.

Minimum Spanning Trees (CLRS 23)

CS 253: Algorithms. Chapter 24. Shortest Paths. Credit: Dr. George Bebis

Section 3: Antiderivatives of Formulas

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

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...

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

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

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

Chapter Interval Scheduling. Greedy Algorithms. What is a Greedy Algorithm? Interval Scheduling

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

1.9 Cartesian Tensors

Filter Design Techniques

Week 3: Connected Subgraphs

4.8 Huffman Codes. Wordle. Encoding Text. Encoding Text. Prefix Codes. Encoding Text

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

Examples and applications on SSSP and MST

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

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 =?

Walk Like a Mathematician Learning Task:

UNIVERSITY OF IOANNINA DEPARTMENT OF ECONOMICS. M.Sc. in Economics MICROECONOMIC THEORY I. Problem Set II

1 Introduction to Modulo 7 Arithmetic

Strongly Connected Components

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

8. Linear Contracts under Risk Neutrality

CS 103 BFS Alorithm. Mark Redekopp

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

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.

Jones vector & matrices

Constructive Geometric Constraint Solving

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

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

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

Heisenberg Model. Sayed Mohammad Mahdi Sadrnezhaad. Supervisor: Prof. Abdollah Langari

Data Structures and and Algorithm Xiaoqing Zheng

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

FINITE ELEMENT ANALYSIS OF

Handout 4. Inverse and Implicit Function Theorems.

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

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

23 Minimum Spanning Trees

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

Basic Polyhedral theory

Last time: introduced our first computational model the DFA.

priority queue ADT heaps 1

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

minimize c'x subject to subject to subject to

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

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

Chapter 6 Continuous Random Variables and Distributions

Applications of trees

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

Connected-components. Summary of lecture 9. Algorithms and Data Structures Disjoint sets. Example: connected components in graphs

1.2. Linear Variable Coefficient Equations. y + b "! = a y + b " Remark: The case b = 0 and a non-constant can be solved with the same idea as above.

CHAPTER 33: PARTICLE PHYSICS

Bridging the gap: GCSE AS Level

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

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski

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

TOPIC 5: INTEGRATION

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

Review - Probabilistic Classification

CONTINUITY AND DIFFERENTIABILITY

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

Ερωτήσεις και ασκησεις Κεφ. 10 (για μόρια) ΠΑΡΑΔΟΣΗ 29/11/2016. (d)

Weighted Matching and Linear Programming

COMPLEX NUMBER PAIRWISE COMPARISON AND COMPLEX NUMBER AHP

Problem solving by search

Transcription:

Mnmum Spnnng Trs Spnnng Tr A tr (.., connctd, cyclc grph) whch contns ll th vrtcs of th grph Mnmum Spnnng Tr Spnnng tr wth th mnmum sum of wghts 1 1 Spnnng forst If grph s not connctd, thn thr s spnnng tr for ch connctd componnt of th grph

Applctons of MST Fnd th lst xpnsv wy to connct st of cts, trmnls, computrs, tc. 3

Exmpl Problm A town hs st of houss nd st of rods A rod conncts nd only houss A rod connctng houss u nd v hs rpr cost w(u, v) 1 1 Gol: Rpr nough (nd no mor) rods such tht: 1. Evryon stys connctd.., cn rch vry hous from ll othr houss. Totl rpr cost s mnmum

Mnmum Spnnng Trs A connctd, undrctd grph: Vrtcs = houss, Edgs = rods A wght w(u, v) on ch dg (u, v) E 1 1 Fnd T E such tht: 1. T conncts ll vrtcs. w(t) = Σ (u,v)t w(u, v) s mnmzd

Proprts of Mnmum Spnnng Trs Mnmum spnnng tr s not unqu MST hs no cycls (by dfnton) : # of dgs n MST: V - 1

Prm s Algorthm Strts from n rbtrry root : V A = {} At ch stp: Fnd lght dg crossng (V A, V - V A ) Add ths dg to st A (Th dgs n st A lwys form sngl tr) Rpt untl th tr spns ll vrtcs 1 1

How to Fnd Lght Edgs Quckly? Us prorty quu Q: Contns vrtcs not yt ncludd n th tr,.., (V V A ) V A = {}, Q = {b, c, d,, f, g, h, } W ssoct ky wth ch vrtx v: ky[v] = mnmum wght of ny dg (u, v) connctng v to V A Ky[] = mn(w 1,w ) w 1 w 1 1

How to Fnd Lght Edgs Quckly? (cont.) Aftr ddng nw nod to V A w updt th wghts of ll th nods djcnt to t.g., ftr ddng to th tr, Ky[b]= nd Ky[h]= Ky[v] = f v s not djcnt to ny vrtcs n V A 1 1

Exmpl 1 1 1 1 0 Q = {, b, c, d,, f, g, h, } V A = Extrct-MIN(Q) ky [b] = [b] = ky [h] = [h] = Q = {b, c, d,, f, g, h, } V A = {} Extrct-MIN(Q) b

Exmpl 1 1 1 1 Q = {c, d,, f, g, h, } V A = {, b} ky [c] = [c] = b ky [h] = [h] = - unchngd Extrct-MIN(Q) c Q = {d,, f, g, h, } V A = {, b, c} ky [d] = [d] = c ky [f] = [f] = c ky [] = [] = c Extrct-MIN(Q)

Exmpl 1 1 1 1 Q = {d,, f, g, h} V A = {, b, c, } ky [h] = [h] = ky [g] = [g] = Extrct-MIN(Q) f Q = {d,, g, h} V A = {, b, c,, f} ky [g] = [g] = f ky [d] = [d] = c unchngd ky [] = [] = f Extrct-MIN(Q) g 1

Exmpl 1 1 1 Q = {d,, h} V A = {, b, c,, f, g} ky [h] = 1 [h] = g 1 Extrct-MIN(Q) h 1 1 1 Q = {d, } V A = {, b, c,, f, g, h} Extrct-MIN(Q) d 13

Exmpl Q = {} V A = {, b, c,, f, g, h, d} 1 1 1 ky [] = [] = d Extrct-MIN(Q) Q = V A = {, b, c,, f, g, h, d, } 1

PRIM(V, E, w, r) 1. Q. for ch u V 3. do ky[u]. π[u] NIL 5. INSERT(Q, u). DECREASE-KEY(Q, r, 0) % ky[r] 0. whl Q. do u EXTRACT-MIN(Q). for ch v Adj[u]. do f v Q nd w(u, v) < ky[v]. thn π[v] u Totl tm: O(VlgV + ElgV) = O(ElgV) O(V) f Q s mplmntd s mn-hp Excutd V tms Tks O(lgV) Excutd O(E) tms totl 1. DECREASE-KEY(Q, v, w(u, v)) O(lgV) Constnt Tks O(lgV) Mn-hp oprtons: O(VlgV) O(ElgV)

Prm s Algorthm Totl tm: O(E lgv ) Prm s lgorthm s grdy lgorthm Grdy lgorthms fnd solutons bsd on squnc of chocs whch r loclly optml t ch stp. Nvrthlss, Prm s grdy strtgy producs globlly optmum soluton! 1

Kruskl s Algorthm How s t dffrnt from Prm s lgorthm? Prm s lgorthm grows on tr ll th tm Kruskl s lgorthm grows multpl trs (.., forst) t th sm tm. tr1 Trs r mrgd togthr usng sf dgs u Snc n MST hs xctly V - 1 dgs, ftr V - 1 mrgs, w would hv only on componnt v tr 1

Kruskl s Algorthm Strt wth ch vrtx bng ts own componnt Rptdly mrg two componnts nto on by choosng th lght dg tht conncts thm Whch componnts to consdr t ch trton? Scn th st of dgs n monotonclly ncrsng ordr by wght 1 1 W would dd dg (c, f) 1

Exmpl 1 1 1: (h, g) : (, h), (b, c) : (c, ), (g, f) : (d, ) : (, b), (c, f) : (, f) : (, g) : (b, h) : (c, d), (, h) 1: (d, f) {}, {b}, {c}, {d}, {}, {f}, {g}, {h}, {} 1. Add (h, g). Add (c, ) 3. Add (g, f). Add (, b) 5. Add (c, f). Ignor (, g). Add (c, d). Ignor (, h). Add (, h). Ignor (b, c). Add (d, ) 1. Ignor (, f) 13. Ignor (b, h) 1. Ignor (d, f) {g, h}, {}, {b}, {c},{d},{},{f},{} {g, h}, {c, }, {}, {b}, {d}, {}, {f} {g, h, f}, {c, }, {}, {b}, {d}, {} {g, h, f}, {c, }, {, b}, {d}, {} {g, h, f, c, }, {, b}, {d}, {} {g, h, f, c, }, {, b}, {d}, {} {g, h, f, c,, d}, {, b}, {} {g, h, f, c,, d}, {, b}, {} {g, h, f, c,, d,, b}, {} {g, h, f, c,, d,, b}, {} {g, h, f, c,, d,, b, } {g, h, f, c,, d,, b, } {g, h, f, c,, d,, b, } {g, h, f, c,, d,, b, }

Implmntton of Kruskl s Algorthm Uss dsjont-st dt structur (s Chptr 1) to dtrmn whthr n dg conncts vrtcs n dffrnt componnts 1 1 W would dd dg (c, f) 0

Oprtons on Dsjont Dt Sts MAKE-SET(u) crts nw st whos only mmbr s u FIND-SET(u) rturns rprsnttv lmnt from th st tht contns u Any of th lmnts of th st tht hs prtculr proprty E.g.: S u = {r, s, t, u}, th proprty s tht th lmnt b th frst on lphbtclly FIND-SET(u) = r FIND-SET(s) = r FIND-SET hs to rturn th sm vlu for gvn st 1

Oprtons on Dsjont Dt Sts UNION(u, v) unts th dynmc sts tht contn u nd v, sy S u nd S v E.g.: S u = {r, s, t, u}, S v = {v, x, y} UNION (u, v) = {r, s, t, u, v, x, y} Runnng tm for FIND-SET nd UNION dpnds on mplmntton. W hd sn rlr tht FIND-SET cn b don n O(lgn) tm nd UNION oprton cn b don n O(1) (s Chptr 1)

KRUSKAL(V, E, w) 1. A. for ch vrtx v V 3. do MAKE-SET(v) O(V). sort E nto non-dcrsng ordr by w 5. for ch (u, v) tkn from th sortd lst. do f FIND-SET(u) FIND-SET(v). thn A A {(u, v)}. UNION(u, v). rturn A O(ElgE) O(E) O(lgV) Runnng tm: O(V+ElgE+ElgV) O(ElgE) dpndnt on th mplmntton of th dsjont-st dt structur Snc E=O(V ), w hv lge=o(lgv)=o(lgv)

Kruskl s Algorthm O(E lge ) or O(E lgv ) Kruskl s lgorthm s grdy It producs globlly optmum soluton