2006 算法设计qiu-lec10

2006 算法设计qiu-lec10

ID:33759849

大小:296.64 KB

页数:9页

时间:2019-03-01

2006 算法设计qiu-lec10_第1页
2006 算法设计qiu-lec10_第2页
2006 算法设计qiu-lec10_第3页
2006 算法设计qiu-lec10_第4页
2006 算法设计qiu-lec10_第5页
资源描述:

《2006 算法设计qiu-lec10》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、图(Graphs)•Applicationsthatinvolvenotonlyasetofitems,butalsothe算法设计与分析connectionsbetweenthem(物体及物体之间的连接关系)AlgorithmsDesign&Analysis第十讲:图的算法ComputernetworksMaps(地图)Schedules(日程表)(计算机网络)华中科技大学软件学院邱德红主讲2005年4月Hypertext(超文本)Circuits(电路板)12图的背景知识(Graphs–Background)图的其它类型(OtherT

2、ypesofGraphs)Graphs=asetofnodes(vertices)withedges•Agraphisconnectedifthereisapath1212(links)betweenthem.(节点+边)betweeneverytwovertices(如果任何两个顶点之间存在一个通路,则称图是连Notations:(表示方法)接的)3434•G=(V,E)–graph(图)ConnectedNotconnected•V=setofvertices⎜V⎜=n(节点和节点数目)•E=setofedges⎜E⎜=m(边和边的数

3、目)•AbipartitegraphisanundirectedgraphG=(V,E)inwhichV=V1+V212121212andthereareedgesonlybetween9verticesinVandV(二分图:无向4812343434图,由V1和V2组成,只在V1和V2之间的367顶点存在边)4DirectedUndirectedAcyclicGraph(有向图)Graph(无向图)Graph(无回路图)34邻接表特性(PropertiesofAdjacency-图的表示方法(GraphRepresentation)Li

4、stRepresentation)•AdjacencylistrepresentationofG=(V,E)(邻接表)•Sumofthelengthsofalltheadjacency–Anarrayof⎜V⎜lists,oneforeachvertexinV(顺序存储的顶点表)12–EachlistAdj[u]containsalltheverticesvsuchthatthereisanedgebetweenuandv(边表:一个顶点的边表的每个表目对应与该顶lists(邻接表长度的和→边的数目)点相关联的一条边)34•Adj[u]c

5、ontainstheverticesadjacenttou(inarbitraryorder)(顺序无关)–Directedgraph:(有向图:边出现一次)–Canbeusedforbothdirectedandundirectedgraphs(适合有向或无Directedgraph向图)•Edge(u,v)appearsonlyonceinu’slist⎜E⎜125/12–Undirectedgraph:(无向图:边出现两次)1221534/33324•uandvappearineachother’sadjacencylists:54

6、544253/edge(u,v)appearstwice2⎜E⎜5412UndirectedgraphUndirectedgraph561邻接表特性(PropertiesofAdjacency-图的表示方法(GraphRepresentation)ListRepresentation)•Memoryrequired(空间需求)•AdjacencymatrixrepresentationofG=(V,E)(相邻矩阵)–Θ(V+E)12–Assumeverticesarenumbered1,2,…⎜V⎜(顶点序号)•Preferredwhen

7、(适合⎜E⎜<<⎜V⎜2)3–TherepresentationconsistsofamatrixA⎜V⎜x⎜V⎜:–thegraphissparse:⎜E⎜<<⎜V⎜254–aij=1if(i,j)∈E(元素值的确定)•Disadvantage(缺陷)0otherwise–noquickwaytodeterminewhetherthereisanUndirectedgraphedgebetweennodeuandv(不容易判断顶点u和v12345之间是否存在边)1212101001Forundirected•Timetolistallv

8、erticesadjacenttou:(罗列与u3211011graphsmatrixA邻接顶点的时间开销)34300011issymmetric:–Θ(degree(u))54•Timeto

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。