[关闭]
@w1024020103 2017-05-19T16:46:22.000000Z 字数 1346 阅读 1209

Lecture 30: Graphs IV: Minimum Spanning Trees

CS61B


MST, Cut Property, Generic MST Algorithm

MST:

image_1bg7ktmgct6p1vhfu6524ki6i9.png-162.1kB

image_1bg7kv1mukaduqor4rt7n1qg2m.png-74.8kB

MST applications:
image_1bg7kvproq141hoa19b011g1jir13.png-442kB

MST VS SPT

image_1bg7l11cj160u1sklqid1vei1nv71g.png-69.1kB

Cut property:

image_1bg7l44681md9hhbqmacgp1g4c1t.png-135.9kB

Cut property proof:
image_1bg7l4qah12garomaus7oo1u302a.png-110.4kB

Prim’s Algorithm

image_1bg7mubn51sf11qmkq0h17f91b5u2n.png-153.9kB

Demo

image_1bg7mvfo5j4c16hbmvme4c1bbl34.png-264.3kB

image_1bg7n0sfl161tr21sug1g973oc3h.png-109.5kB

Pseudocode:

1.JPG-74.3kB

2.JPG-90.5kB

3.JPG-73.9kB

Runtime:

4.JPG-76.9kB

Kruskal’s Algorithm

Demo

image_1bgcn78lg17jpcto1d581p6n15k39.png-148.4kB

Prim's VS Kruskal's

image_1bgcn8r2g13nrc0i1eohmnkhltm.png-251.1kB

Kruskal's pseudocode

image_1bgcndujp11eg14s2m8q13e01hrg13.png-282.5kB

Runtime

image_1bgcng0ov1jkr13pdkkq1vu1uet1g.png-86kB

Shortest Path and MST algorithm Summury

image_1bgcnhd7n1tgrr4r15ls148m1iqp1t.png-86.6kB

Minimum Spanning Trees, Kruskal's, Prim's

Overview

image_1bgcnm3mlpuj1e1111pbjsf1d8g2a.png-45.3kB

image_1bgcnn1381qrbpqa7h1k7pcle2n.png-18.8kB

image_1bgcnvve6t9n11n0l3vbdd1cl34.png-91.5kB

image_1bgco121h1s4i1kg315v61a88gd83h.png-71.1kB

C LEVEL

2.Problem 2 from Princeton's Spring 2008 final
image_1bgcoslg4rmo1qpo1hnr1a7uhv23u.png-107.4kB

image_1bgcp1ke31aehui7qd7tuk14h84b.png-11.4kB

Normally in alphabetic oder.

3.Would Kruskal or Prim's algorithm work on a directed graph?
No.

4.True or false: Adding a constant to every edge weight does not change the solution to the MST problem.
TRUE

image_1bgcr0mn61pun1fg512is1jue2o2m.png-142.9kB

B level

1.Adapted from Algorithms 4.3.8. Prove the following, known as the cycle property: Given any cycle in an edgew eighted graph (all edge weights distinct), the edge of maximum weight in the cycle does not belong to the MST of the graph.

这题用反证法,首先MST的定义要清楚:

image_1bgdtju9arbaj6m1r3r16jb1n899.png-25.8kB

假设the edge of maximum weight in the cycle在MST T1里,为edge e. 我们删掉C,那T1就会分成两部分,e的两个端点分别在两不同部分。cycle里其他的edge重新连接这两部分,比如edge f重新连接,形成新的MST T2. 这样的话,T1的总weights大于T2了,与T1是graph的MST矛盾。所以原假设不成立,圆里maximum weight的edge不可能属于图的MST.

image_1bgdu03u6dp66o81n4rujmpejm.png-35.9kB

Minimum spanning tree

2.Problem 3 from Princeton's Fall 2009 final (part d is pretty hard).
5.jpg-272.1kB

3.Problem 4 from Princeton's Fall 2012 final.
6.jpg-110.1kB

4.Adapted from Algorithms 4.3.12. Suppose that a graph has distinct edge weights. Does its shortest edge have to belong to the MST? Can its longest edge belong to the MST? Does a min-weight edge on every cycle have to belong to the MST? Prove your answer to each question or give a counterexample.

7.jpg-74.2kB

Minimum-cost edge

image_1bgfbeuev17nc91eirs19ta16ug1h.png-21.1kB

Cycle property

image_1bgfbg6lu1b091j2p16fvp1o12jd1u.png-36.1kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注