Ltur II: Mnmum Spnnn Tr Alortms Dr Krn T. Hrly Dprtmnt o Computr Sn Unvrsty Coll Cork Aprl 0 KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Mnmum Spnnn Trs Mnmum Spnnn Trs Spnnn Tr tr orm rom rp s tt tous vry no (.. vy s ov) Mnmum Spnnn Tr (MST) spnnn tr wt mnmum totl wt tr wt = sum o wts MST n not unqu KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Mnmum Spnnn Trs Som Trmnoloy A ut prtton o V nto two sts S n V S E (u, v) rosss ut on npont s n S, t otr n V S Cut rspts st A E no n A rosss t ut KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Mnmum Spnnn Trs An I St A E s xtnl A s sust o som MST. E (u, v) A s s or A A {(u, v)} s lso xtnl. Crt MST y rown t y : Alortm GnrMST(G): Crt mpty st A wl A os not spn ll nos o n (u, v) s or A (u, v) to A rturn A KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Mnmum Spnnn Trs Fnn S Es Lt Nos(A) = nos spnn y A. Clm Cpst rp s s or A =. Clm For xtnl A, t pst (u, v) rossn ut (Nos(A), V Nos(A)) s s or A. KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 5 / 5
Mnmum Spnnn Trs Proo o Clm Clm For xtnl A, t pst (u, v) rossn ut (Nos(A), V Nos(A)) s s or A. Suppos S ontnn A s n MST tt os not nlu (u, v). S (u, v) ontns yl. Som (x, y) S lso rosss ut. wt(u, v) wt(u, v) y o o (u, v). Tus, S mnus (x, y) plus (u, v) ontns A spns V s mn. wt KH (/0/) Ltur II: Mnmum Spnnn Tr.. Alortms (u, v) s s oraprl A. 0 / 5
Kruskl s Alortm Kruskl s lortm: t s Strt wt orst o n on-no trs Sort s n non-nrsn orr. Tk n turn: rs two rnt trs, mrk (n mr trs); otrws, nor t n mov on, T mrk nos onsttut MST. KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm K s lortm 0 Fur 3. rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm Dsjont st t strutur (s CLRS C. ) Wt Collton o sjont ynm susts ovr som st o lmnts; Hr susts r t trs wtn orst Oprtons mk st(x) rt nw snlton st ontnn x n st(x) nty t sust to w x lons unon(x, y) omn t two susts to w x n y lon. Implmntton Lnk strutur; s CLRS.3; O(mα(n)) or ny m oprtons (α vry slowly rown unton lmost onstnt ). KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Kruskl s Alortm Kruskl Alortm MST Kruskl(G, w): A mpty st or v n G.V o mk st(v) sort s n G.E n nonrsn orr y wt or (u, v) n G.E n orr o n st (u) n st (v) tn A A unon {(u, v)} unon(u, v) rturn A KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 0 / 5
Kruskl s Alortm Runnn tm n, m = num. nos, s Intlzton (n mk sts): O(n) Sortn s: O(m lo n) Loop (m trtons): m n sts m unons.. mα(n) n ll Totl: O(m lo m) α(n) lo(n) KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm Prm s t s Grow (snl) tr T rom som strtn pont At stp: Consr t rn o T.. s wt on no ns tr n on outs Coos t pst su (u, v) n norport t (n no v) nto t tr. (Not ts s s o so w lwys xpn t tr sly.) KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm P s lortm n ton 0 3 3 Fur 3.5 rom CLRS KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
Prm s Alortm Prm s Alortm Lt Q prorty quu ontnn t nos. E no ntlly s ky xpt or r w s ky 0. Alortm Prm(G, r): Crt Q s ov. Crt mpty tr T. wl Q s not mpty o u Q.rmov\ mn() or v n G.nours(u) o v n Q n wt(u, v) < ky(v) mk v l o u n T ky(v) wt(u, v) rturn T KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm Prm s Alortm o Alortm Prm(G, r): Crt Q s ov; Crt mpty tr T. wl Q s not mpty o u Q.rmov\ mn() or v n G.nours(u) o v n Q n wt(u, v) < ky(v) mk v l o u n T ky(v) wt(u, v) rturn T Prorty quu Q: Q ols nos not yt n mryon MST non-q nos onsttut tr-so-r KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 5 / 5
Prm s Alortm Invrnt Invrnt: T (Q) s sust o n MST or v Q, n T toun v s t ltst jonn v to ny no n Q ky(v) s t wt o tt KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm Clm 3 Clm: Lt Q = nos not n Q; T (Q) = s rom T jonn nos n Q, tn nvrnt ols t t nnn (n n) o trton. Prm T (Q) Gnr MST A KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm Proo o Clm 3 (Skt) Alortm Prm(G, r): Crt Q s ov. Crt mpty tr T. wl Q s not mpty o u Q.rmov\ mn() or v n G.nours(u) o v n Q n wt(u, v) < ky(v) mk v l o u n T ky(v) wt(u, v) Invrnt tru ntlly: T (Q) mpty E trton prsrvs t nvrnt: No u osn y rmov mn Impltly, () u lvs Q n jons Q n () (u, prnt T (u)) jons T (Q) E (u, prnt T (u)) s y o o u For loop upts ky(v) or nours o u to mntn loop nvrnt only s toun u n r-onsr KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
Prm s Alortm Runnn Tm Alortm Prm(G, r): Crt Q s ov. Crt mpty tr T. wl Q s not mpty o u Q.rmov\ mn\ lmnt() or v n G.nours(u) o v n Q n wt(u, v) < ky(v) mk v l o u n T ky(v) wt(u, v) Crton o Q: O(n) No. o wl loop trtons: n Prorty quu ops rmov mn lmnt O(lo n) n rpl ky O(lo n) ( Contruton o or loop: For u = x, #trtons = #nours o x; Ovrll, #trtons = m. Totl runnn tm: O(m lo n). KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
MST Appltons Applton Gnr prolm ow to lnk totr ollton o ojts ply wr lnk ost s proportonl to stn twn ojts. Exmpls Ol-ollton pplns: ojts = wlls; lnks = pplns twn wlls; (lnk ost prop. to lnt) Computr ntworks: ojts = nvul sts; lnks = t lns; (lnk ost = montly rntl ) KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 0 / 5
MST Appltons Ptur KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
MST Appltons Mol s rp wt G = (V, E) V = wll postons; E = ll possl wll-to-wll pplns; wt quls stn quls ost. MST vs st o pplns (s) tt onnt vry wll-; v mnml totl lnt. (Mor sopstt ppro mt tk onsr Non-unorm ppln osts; Lnks otr tn wll-to-wll lnks.) KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5
MST Appltons Applton Lt unrt G rprsnt omputr ntwork wr wts not rprol o lnk nwts. T vlu o pt π s ts mxmum wt. How to trmn or pr u, v t mnmum vlu pt jonn tos nos? KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 3 / 5
MST Appltons Clm: E n G rom S to V S ws t lst wt(u, v). Evry pt π rom u to v ontns on su n must v vlu KH (/0/) t lst wt(u, Ltur II: v). Mnmum Spnnn Tr Alortms Aprl 0 / 5 Lt T n MST or G. Lt (u, v) not mx. n unqu pt π n T rom u to v. Pt π s vlu wt(u, v). Dltn (u, v) prttons nos nto sjont sts.
MST Appltons Applton 3 Clustr Anlyss Prtton xprmntl t nto lustrs; Clustr mmrs mor losly rlt to on notr tn non-lustr mmrs. Applton Plrsm tton: Dt prorms sumtt Clustrs suspously smlr sumssons? Ml tstn: Dt ptnt msurmnts or vrous symptoms; Clustrs roups o smlrly t ptnts. KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 5 / 5
MST Appltons Ptur KH (/0/) Ltur II: Mnmum Spnnn Tr Alortms Aprl 0 / 5