开发三道工序课件_第1页
开发三道工序课件_第2页
开发三道工序课件_第3页
开发三道工序课件_第4页
开发三道工序课件_第5页
已阅读5页,还剩139页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论