cmu 15 251
play

CMU 15-251 Graph Algorithms Teachers: Anil Ada Ariel Procaccia - PowerPoint PPT Presentation

CMU 15-251 Graph Algorithms Teachers: Anil Ada Ariel Procaccia (this time) Depth-First Search For each 7 unexplored 6 1 DFS( ,u) o DFS(graph , ) 3 mark as explored 5 2 for each


  1. CMU 15-251 Graph Algorithms Teachers: Anil Ada Ariel Procaccia (this time)

  2. Depth-First Search β€’ For each 7 unexplored 𝑣 ∈ π‘Š 6 1 DFS( 𝐻 ,u) o DFS(graph 𝐻 , 𝑣 ∈ 𝐹 ) 3 β€’ mark 𝑣 as explored 5 2 β€’ for each {𝑣, 𝑀} ∈ 𝐹 4 if 𝑀 is o unexplored then DFS( 𝐻, v ) 𝑃(𝑛 + π‘œ) 2

  3. Graph Search Problems 𝐻 β€’ o 𝑑 𝑒 𝐻 o 𝐻 o β€’ 3

  4. Topological Sorting 𝐻 β€’ 𝑔: π‘Š β†’ {1, … , π‘œ} 𝑣, 𝑀 ∈ 𝐹 𝑔 𝑣 < 𝑔(𝑀) 𝑏 𝑐 𝑑 𝑒 𝑓 𝑒 𝑏 𝑐 𝑑 𝑓 4

  5. Topological Sorting 15 251 21 127 15 15 15 451 112 150 15 122 15 210 5

  6. Topological Sorting β€’ 𝑣, 𝑀 ∈ π‘Š 𝑣, 𝑀 ∈ 𝐹 β€’ 6

  7. Topological Sorting β€’ β€’ β€’ β€’ 7

  8. Proof of Lemma β€’ β€’ π‘œ ∎ 8

  9. NaΓ―ve Algorithm β€’ π‘ž ← π‘œ β€’ while π‘ž β‰₯ 1 3 If the graph doesn’t o have a sink then 4 5 2 return β€œnot acyclic” else find a sink 𝑀 and o 1 remove it from 𝐻 𝑔 𝑀 ← π‘ž o π‘ž ← π‘ž βˆ’ 1 o 9

  10. Better Algorithm Via DFS β€’ π‘ž ← π‘œ β€’ For each unexplored 𝑣 ∈ π‘Š , DFS( 𝐻 ,u) 3 DFS(graph 𝐻 , 𝑣 ∈ 𝐹 ) β€’ mark 𝑣 as explored 4 5 2 β€’ for each {𝑣, 𝑀} ∈ 𝐹 , if 𝑀 is unexplored then DFS( 𝐻, v ) 1 β€’ 𝑔 𝑣 ← π‘ž β€’ π‘ž ← π‘ž βˆ’ 1 10

  11. Correctness 𝐻 𝑣, 𝑀 ∈ 𝐹 β€’ 𝑔 𝑣 < 𝑔(𝑀) β€’ 𝑣 𝑀 o 𝑣, 𝑀 ∈ 𝐹 𝑀 (𝐻, 𝑣) 𝑀 𝑣 o 𝑣 (𝐻, 𝑀) (𝐻, 𝑣) (𝐻, 𝑀) ∎ 11

  12. Weighted Graphs β€’ 8 5 o 10 o 2 3 18 16 o 12 30 o 14 β€’ 4 26 β€’ 𝑑: 𝐹 β†’ ℝ + 12

  13. Minimum Spanning Tree 13

  14. 14

  15. Minimum Spanning Tree β€’ 𝐻 o 8 5 𝑑: 𝐹 β†’ ℝ + 10 𝐹 β€² βŠ† 𝐹 o 2 3 π‘Š, 𝐹 β€² 18 16 12 30 π‘“βˆˆπΉ β€² 𝑑 𝑓 14 4 26 β€’ 42 15

  16. 16

  17. Number of MSTs β€’ β€’ 𝑧 𝑦 𝑨 17

  18. 18

  19. Prim’s Algorithm β€’ π‘Š β€² ← 𝑣 , 𝐹 β€² ← βˆ… β€’ While π‘Š β€² β‰  π‘Š 8 5 5 o Let (𝑣, 𝑀) be a 10 minimum cost edge 2 2 3 3 18 16 16 such that 𝑣 ∈ π‘Š β€² , 12 12 30 𝑀 βˆ‰ π‘Šβ€² 14 o 𝐹 β€² ← 𝐹 βˆͺ 4 4 26 𝑣, 𝑀 o π‘Š β€² ← π‘Š β€² βˆͺ {𝑀} 19

  20. 20

  21. Proof of Correctness π‘ˆ β€’ 0 ≀ 𝑙 ≀ π‘œ 𝑙 π‘ˆ β€’ 𝑙 = 0) β€’ β€’ 𝑙 21

  22. Proof of Correctness π‘Š β€² β€’ 𝑓 = {𝑏, 𝑐} β€’ 𝑏 𝑓 β€’ 𝑓 𝑑 π‘ˆ 𝑓′ β€’ π‘ˆ a β†’ 𝑐 𝑒 𝑐 𝑓 β€² = (𝑑, 𝑒) β€’ π‘Šβ€² 22

  23. Proof of Correctness π‘ˆ β€² = π‘ˆ βˆͺ 𝑓 βˆ– {𝑓 β€² } β€’ π‘ˆ o π‘œ βˆ’ 1 o 𝑏 β€’ π‘ˆβ€² 𝑓 𝑑 𝑣 β†’ 𝑑 β†’ 𝑒 β†’ 𝑀 𝑓′ 𝑓′ 𝑒 𝑐 𝑣 β†’ 𝑑 β†’ 𝑏 β†’ 𝑐 β†’ 𝑒 β†’ 𝑀 π‘ˆ ∎ β€’ 23

  24. 24

  25. π‘Šβ€² 25

  26. The MST Cut Property 𝐻 β€’ π‘Š β€² βŠ† π‘Š 𝑓 π‘Šβ€² π‘Š βˆ– π‘Šβ€² 𝑓 β€’ β€’ o o 26

  27. Run-Time Race for MST β€’ 𝑃 𝑛 2 β€’ 𝑃(𝑛 log 𝑛) β€’ β€’ β€’ 27

  28. Run Time Race for MST 𝑃(𝑛 log 𝑛) β†’ 𝑃(𝑛 log βˆ— 𝑛) 28

  29. Run Time Race for MST 𝑃(𝑛 log βˆ— 𝑛) β†’ 𝑃(𝑛 log(log βˆ— 𝑛)) 29

  30. Run Time Race for MST 𝑃(𝑛 log(log βˆ— 𝑛)) β†’ 𝑃(𝑛 β‹… 𝛽 𝑛 ) 𝛽 β‹… ? 30

  31. Detour: 𝛽(β‹…) β€’ log βˆ— 𝑛 = log 2 β€’ log βˆ—βˆ— (𝑛) = log * 2 β€’ log βˆ—βˆ—βˆ— (𝑛) = log ** 2 β€’ log βˆ—β‹―βˆ— 𝑛 ≀ 2 β€’ 𝛽 𝑛 = 31

  32. Run Time Race for MST β€’ β€’ 32

  33. Summary β€’ o o o β€’ o o o β€’ o 33

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend