版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1Chapter15
Graphs,Trees,andNetworks2Chap.1515.1UndirectedGraphs15.2DirectedGraphs15.3Trees15.4Networks15.5GraphAlgorithms
MinimumSpanningTreeShortestPath3
Chap.15(Cont.)15.6NetworkClass開發三道工序:4Graphtheory圖論
FromWikipedia,thefreeencyclopediaInmathematicsandcomputerscience,graphtheoryisthestudyofgraphs,mathematicalstructuresusedtomodelpair-wiserelationsbetweenobjectsfromacertaincollection.
某collection的objects的兩兩關係5ApplicationsofGraphs
許多實際問題可用graph來表示。例如連接結構的一個網站,可以用有向圖(directedgraph):頂點(vertex)是網頁網址,如果有一個網頁B連結到網頁A,便有個連結(edge)在兩者A,B之間。
類似的,在travel問題,生物學,computerchip的設計,以及其他許多領域。開發algorithm來處理graph,因此主要應用是在computerscience。
graph可延伸為weighted
graph
(加權圖)。
例如,weight能夠代表連結(edge)的長度。615.1UndirectedGraphs7 Example:
X
YZTAns:
5Vertices
6EdgesST,YX,YS,T(SameasT,S)TCTVAssumetheedgesareinsertedintothegraphasfollows:Y,V,T XS,T(SameasT,S)Chapter15SCTrees,andX,Y,T,Z,Xisacycle.HashSetTreeSetV,ZS,Zbetween2verticesbedetermined?Wewillcoverthat.C8Collection
ListSet
ArrayListLinkedListSortedSet
HashSetTreeSet9101112X
YZTX,Y,T,Z,Shaslength4.ShortestpathfromXtoS=?
Ans:2
SIngeneral,howcanthesmallestpath
between2verticesbedetermined?
Wewillcoverthat.1314X
YZTX,Y,T,Z,Xisacycle.Y,T,S,Z,T,Yisnotacycle.(repeatededges:YTandTY)SIsY,Z,T,S,Z,X,Yacycle?
Yes!15Collection
ListSet
ArrayListLinkedListSortedSet
HashSetTreeSetThisundirectedgraphisacyclic.16171815.2DirectedGraphsthealgorithmisthesame,but“neighbor”takesintoaccountS,T(SameasT,S)XxvV,XS(repeatededges:YTandTY)SStartingatA,theneighborsofAareBandC,butnotD.thealgorithmisthesame,but“neighbor”takesintoaccountCollectionSYZ6NetworkClass開發三道工序:A類似的,在travel問題,生物學,computerchip的設計,以及其他許多領域。CollectionS,T//SameasT,ST,Z STMinimumSpanningTree19202122232415.3Trees25Collection
ListSet
ArrayListLinkedListSortedSet
HashSetTreeSet2615.4Networks2728ListSetbetween2verticesbedetermined?Wewillcoverthat.HashSetTreeSetX,Y,T,Z,Xisacycle.5
GraphAlgorithmsListSetqueue Vertexreturnedbynext()Ingeneral,howcanthesmallestpathListSetTrees,andXT5VerticesmarkCthepredecessorofBYZ(repeatededges:YTandTY)SForabreadth-firstiterationofadirectedgraph,AYZ某collection的objects的兩兩關係5Verticesthealgorithmisthesame,but“neighbor”takesintoaccountmarkCthepredecessorofBInmathematicsandcomputerscience,graphtheoryisthestudyofgraphs,mathematicalstructuresusedtomodelpair-wiserelationsbetweenobjectsfromacertaincollection.2DirectedGraphsXListSetShortestPathBCDbetween2verticesbedetermined?Wewillcoverthat.2DirectedGraphs(repeatededges:YTandTY)SS,ZNetworkClassCollection6EdgesX,V,T ZIsY,Z,T,S,Z,X,Yacycle?Yes!2DirectedGraphsZ,Y TV,X某collection的objects的兩兩關係2930313215.5
GraphAlgorithms333435
xvYZT
SAssumetheverticesareenteredinalphabeticalorder.Performabreadth-firstiterationfromS.
Ans:S,T,Z,Y,V,X
3637383940X
V
YZTS41Assumetheedgesareinsertedintothegraphasfollows:
S,T(SameasT,S)
S,Z
T,Y
T,Z
V,X
V,Z
X,Y
X,ZPerformabreadth-firstiterationfromS.42
queue
Vertexreturnedbynext()ST,Z SZ,Y TY,V,X ZV,X YX VXenqueuedequeue43V,ZYZT,YPerformabreadth-firstiterationfromS.HashSetTreeSetCollectionYZYZListSetS,T(SameasT,S)Y,V,X ZXVCollection1UndirectedGraphsInmathematicsandcomputerscience,graphtheoryisthestudyofgraphs,mathematicalstructuresusedtomodelpair-wiserelationsbetweenobjectsfromacertaincollection.StartingatA,theneighborsofAareBandC,butnotD.Tbetween2verticesbedetermined?Wewillcoverthat.YZYZListSetAssumetheedgesareinsertedintothegraphasfollows:444546Forabreadth-firstiterationofadirected
graph,thealgorithmisthesame,but“neighbor”takesintoaccountthedirectionofthearrow.A
BCDStartingatA,theneighborsofAareBandC,butnotD.DNEVER
getsenqueued,andnevergetsreturnedbynext().4748Collection
ListSet
ArrayListLinkedListSortedSet
HashSetTreeSet4950A
Stack!51X
V
YZTS52Assumetheedgesareinsertedintothegraphasfollows:
S,T//SameasT,S
S,Z
T,Y
T,Z
V,X
V,Z
X,Y
X,ZPerformadepth-firstiterationfromS.53
Stack Vertexreturnedbynext()
S
Z,T
SX,V,T ZY,V,T X
V,T Y
TV TTopBottom545556575859606162636465YZqueue Vertexreturnedbynext()ApplicationsofGraphsbetween2verticesbedetermined?Wewillcoverthat.X,Y,T,Z,Xisacycle.(repeatededges:YTandTY)Squeue Vertexreturnedbynext()Performabreadth-firstiterationfromS.X,Y,T,Z,Xisacycle.markCthepredecessorofB1UndirectedGraphsbetween2verticesbedetermined?Wewillcoverthat.thealgorithmisthesame,but“neighbor”takesintoaccountPerformadept
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 请起草一份该制度
- 记事本奖金制度
- 行政单位会计信息化制度
- 2026年上半年牡丹江市事业单位公开招聘工作人员817人参考考试题库附答案解析
- 2026贵州黔东南州公安局面向社会招聘警务辅助人员37人备考考试试题附答案解析
- 2026广东阳江市阳西县招聘高中教师25人参考考试题库附答案解析
- 2026中国科学院上海生命科学研究院生物化学与细胞生物学研究所分子细胞卓越中心杨巍维组招聘科研助理参考考试题库附答案解析
- 2026公安部直属事业单位郑州警察学院招聘55人备考考试试题附答案解析
- 2026新疆乌鲁木齐市第三十六中学诚聘初高中教师18人备考考试试题附答案解析
- 2026年度延边州教育局所属事业单位教师专项招聘(53人)参考考试试题附答案解析
- 神经外科出科考试试题(含答案)
- 职业能力提升行动培训课程标准-03短视频创意编导
- 揿针教学课件
- 医疗知识图谱企业制定与实施新质生产力项目商业计划书
- 工程教育专业认证汇报:做好工程认证与专业建设
- 做人做事培训课件
- 北师大版八年级上册数学全册教案
- 预制板粘贴碳纤维加固计算表格
- 2025年鸡饲料采购合同
- AQ 2001-2018 炼钢安全规程(正式版)
- JBT 14850-2024 塔式起重机支护系统(正式版)
评论
0/150
提交评论