07 - Graphs

791 views

Published on

I used this set of slides for the lecture on Graphs I gave at the University of Zurich for the 1st year students following the course of Formale Grundlagen der Informatik.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
791
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

07 - Graphs

  1. 1. Graphs www.tudorgirba.com
  2. 2. G = (V, E)E = { {u,v} | u,v ∈ V} a e c d g b f
  3. 3. G = (V, E)E = { {u,v} | u,v ∈ V} a e c d g b fV = { a, b, c, d, e, f, g }E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
  4. 4. G = (V, E)E = { {u,v} | u,v ∈ V} a e c d g b fV = { a, b, c, d, e, f, g }E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
  5. 5. a b c d e f ga 0 1 1 0 0 0 0b 0 0 1 0 0 0 0 a ec 0 0 0 1 0 0 0 c d gd 0 0 0 0 1 1 0e 0 0 0 0 0 0 1 b ff 0 0 0 0 0 0 1g 0 0 0 0 0 0 0
  6. 6. a b c d e f ga 0 1 1 0 0 0 0b 1 0 1 0 0 0 0 a ec 1 1 0 1 0 0 0 c d gd 0 0 1 0 1 1 0e 0 0 0 1 0 0 1 b ff 0 0 0 1 0 0 1g 0 0 0 0 1 1 0
  7. 7. a b c d e f ga 0 1 1 0 0 0 0 2 2b 1 0 1 0 0 0 0 a ec 1 1 0 1 0 0 0 c d gd 0 0 1 0 1 1 0 3 3 2e 0 0 0 1 0 0 1 b ff 0 0 0 1 0 0 1 2g 0 0 0 0 1 1 0 2 2 3 3 2 2 2 Degree of a node
  8. 8. a b c d e f ga 0 2 3 0 0 0 0b 0 0 1 0 0 0 0 a e 3 5 3c 0 0 0 2 0 0 0 2 2 c d gd 0 0 0 0 5 4 0 1 4 3e 0 0 0 0 0 0 3 b ff 0 0 0 0 0 0 3g 0 0 0 0 0 0 0 Weighted graphs
  9. 9. Not complete Complete a a c c b b a a c c b b
  10. 10. G = (V, E)∀ e={v,w} ∈ E, v ∈ V and w ∈ W. Bipartite Not bipartite
  11. 11. Path Cycle a e c d g b fPath: (b, a, c); Length (b, a, c) = 2Path: (b, d, f)Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  12. 12. Path Cycle a e c d g b fPath: (b, a, c); Length (b, a, c) = 2Path: (b, d, f)Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  13. 13. Path Cycle a e c d g b fPath: (b, a, c); Length (b, a, c) = 2Path: (b, d, f)Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  14. 14. Loop-free Loopa e a e c d g c d gb f b f
  15. 15. a e c d gb f
  16. 16. Eulerian patha e a e c d g c d gb f b f
  17. 17. Hamiltonian path Eulerian patha e a e c d g c d gb f b f
  18. 18. Spanning tree Components ea e d g c d g fb f a G = (V, E). T ⊆ E. c
  19. 19. a Critical node e c d gb Critical edge f
  20. 20. Biconnected componentsa e c d gb f
  21. 21. G = (V, E)G1 = (V1, E1)E1 = {{u,v}∈ E | u,v ∈ V1} ⊆ E. a eSubgraph c d g Not subgraph b f
  22. 22. Weakly reachable = exists undirected path a e c d g b fStrongly reachable = exists directed path
  23. 23. 9 F E 6 2 11 D 14 C 9 15 10 A 7 B ithm i jkstr a algor Exa mple: Dhttp://scg.unibe.ch/download/lectures/ei/01ComputationalThinking.pptx
  24. 24. 9 F E 6 2 11 D14 C 9 15 10 A 7 B ithm i jkstr a algor Exa mple: D
  25. 25. ∞ 9 F∞ E 6 2 ∞ ∞ 11 D 14 C 9 15 100 A 7 B ∞ ithm i jkstr a algor Exa mple: D
  26. 26. ∞ 9 F14 E 6 2 ∞ 9 11 D 14 C 9 15 100 A 7 B 7 ithm i jkstr a algor Exa mple: D
  27. 27. ∞ 9 F14 E 6 2 7 + 15 = 22 9 < 7 + 10 11 D 14 C 9 15 100 A 7 B 7 ithm i jkstr a algor Exa mple: D
  28. 28. ∞ 9 F14 > 9 + 2 E 6 2 22 > 9 + 11 9 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  29. 29. 20 9 F11 E 6 2 20 9 11 D 14 C 9 15 100 A 7 B 7 ithm i jkstr a algor Exa mple: D
  30. 30. 20 < 20 + 6 9 F11 E 6 2 20 9 11 D 14 C 9 15 100 A 7 B 7 ithm i jkstr a algor Exa mple: D
  31. 31. a b c d e f g a 0 2 3 0 0 0 0a e b 0 0 1 0 0 0 0 3 5 3 2 c 0 0 0 2 0 0 02 c d g d 0 0 0 0 5 4 0 1 4 3 e 0 0 0 0 0 0 3b f f 0 0 0 0 0 0 3 g 0 0 0 0 0 0 0 Warshall : Floyd Example
  32. 32. a b c d e f g a 0 2 3 0 0 0 0 a e b 0 0 1 0 0 0 0 3 5 3 2 c 0 0 0 2 0 0 02 c d g d 0 0 0 0 5 4 0 1 4 3 e 0 0 0 0 0 0 3 b f f 0 0 0 0 0 0 3 g 0 0 0 0 0 0 0procedure FloydWarshall () for k := 1 to n for i := 1 to n for j := 1 to n path[i][j] = min ( path[i][j], path[i][k]+path[k][j] ); Warshall : Floyd E xample
  33. 33. ing sa lesman l : TraveExample
  34. 34. Tudor Gîrba www.tudorgirba.comcreativecommons.org/licenses/by/3.0/

×