- 2
- 0
- 约7.73千字
- 约 32页
- 2026-02-27 发布于北京
- 举报
公告:MP7已发布。EC截止日期为12/1,晚上
11:59。截止日期为12/8,晚上11:59。
期末考试:12/12,下午1:30‑4:30,考场待定
复习:12/8,晚上7‑9点,Siebel1404
今:
天
算法‑最小生成树,单源最短路径(简介)
||||
最小生成树算法:==
‑输入:连通无向图G,边权重无约束输出:具有以下特征的图G’‑
′′′
⋅是的生成子图⋅连通且无环(一棵树)⋅在所
有这样的生成树中总权重最小
Kruskal算法:不相交集
Suts
优先队列——按权重排序的边
Prim算法示例‑
Announcements:
MP7available.ECDue12/1,11:59p.Due12/8,11:59p.
Finalexam:12/12,1:30-4:30p,roomstba
Review:12/8,7-9p,Siebel1404
Today:
Algorithms-MST,singlesourceshortestpath(intro)
||||
MinimumSpanningTreeAlgorithms:==
-Input:connected,undirectedgraphGwithunconstrainededgeweights
Output:agraphG’withthefollowingcharacteristics-
⋅isaspanningsubgraphof
′
⋅isconnectedandacyclic(atree)
′
⋅hasminimaltotalweightamongallsuchspanningtrees
Kruskal’s:Disjuts
PriorityQueue-edgesorderedbywt.
ExampleofPrim’salgorithm-
初始化结构:SD。
对于所有v,d[v]=“无穷大”,p[v]=
null2.初始化源点:[]
ds=03.初始化优先级
(最小)队列4.初始化已标记顶点集合为∅
done
重复以下步骤n次:
找到并移除具有最小d[]的未标记顶点:vABCEF标记顶点v
对于所有未标记的邻居
,如果cost(,)[]
=cost(
=
∴可能花费
Initializestructure:oSD.
Forallv,d[v]=“infinity”,p[v]=null
[]
2.Initializesource:ds=0
3.Initializepriority(min)queue
4.Initializesetoflabeledverticesto∅
done
Repeatthesestepsntimes:
Findremoveminimumd[]unlabelledvertex:vABCEF
Labelvertexv
()[
原创力文档

文档评论(0)