1 / 45

Depth-First Search Algorithm

b. d. a. c. d. d. a. b. b. e. a. ·. ·. ·. ·. ·. ·. ·. ·. ·. ·. ·. a. a. e. d. b. c. Depth-First Search Algorithm. dfs ( a ) a .marked  1 print a for each ( a , u)  E if (u.mark != 1) dfs (u). dfs(“a”). a. ·. b. ·. c. ·. d. ·.

patia
Download Presentation

Depth-First Search Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. b d a c d d a b b e a · · · · · · · · · · · a a e d b c Depth-First Search Algorithm dfs ( a ) a.marked  1 print a for each (a, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... a · b · c · d · e · EE 5301 - VLSI Design Automation I

  2. e a d a c d d b a b b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( a ) a.marked  1 print a for each (a, u)  E if (b.mark != 1) dfs (b) dfs(“a”) .... dfs(“b”) .... u=b a a · b · c · d · e · EE 5301 - VLSI Design Automation I

  3. d a c d d b a e b a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( b ) b.marked  1 print b for each (b, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... a b a · b · c · d · e · EE 5301 - VLSI Design Automation I

  4. e a d a c d d b a b b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( b ) b.marked  1 print b for each (b, u)  E if (a.mark != 1) dfs (a) dfs(“a”) .... dfs(“b”) .... u=a a b a · b · c · d · e · EE 5301 - VLSI Design Automation I

  5. c d a e b b d a d a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( b ) b.marked  1 print b for each (b, u)  E if (d.mark != 1) dfs (d) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... u=d a b a · b · c · d · e · EE 5301 - VLSI Design Automation I

  6. e a d a c d d b a b b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( d ) d.marked  1 print d for each (d, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... a b d a · b · c · d · e · EE 5301 - VLSI Design Automation I

  7. c a a d b b d d b a e · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( d ) d.marked  1 print d for each (d, u)  E if (e.mark != 1) dfs (e) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... u=e dfs(“e”) .... a b d a · b · c · d · e · EE 5301 - VLSI Design Automation I

  8. c d a e b b d a d a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( e ) e.marked  1 print e for each (e, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... dfs(“e”) .... a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  9. c a a d b b d d b a e · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( e ) e.marked  1 print e for each (e, u)  E if (d.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... u=d dfs(“e”) .... a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  10. c d a e b b d a d a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( e ) e.marked  1 print e for each (e, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... dfs(“e”) .... a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  11. c d a e b b d a d a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( d ) d.marked  1 print d for each (d, u)  E if (b.mark != 1) dfs (b) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... u=b,a a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  12. e a d a c d d b a b b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( d ) d.marked  1 print d for each (d, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... dfs(“d”) .... a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  13. d a c d d b a e b a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( b ) b.marked  1 print b for each (b, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“b”) .... a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  14. d a c d d b a e b a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( a ) a.marked  1 print a for each (a, u)  E if (d.mark != 1) dfs (d) dfs(“a”) .... u=d a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  15. b d a c e d d b a a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( a ) a.marked  1 print a for each (a, u)  E if (c.mark != 1) dfs (c) dfs(“a”) .... dfs(“c”) .... u=c a b d e a · b · c · d · e · EE 5301 - VLSI Design Automation I

  16. d a c d d b a e b a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( c ) c.marked  1 print c for each (c, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“c”) .... a b d e c a · b · c · d · e · EE 5301 - VLSI Design Automation I

  17. e a d a c d d b a b b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( c ) c.marked  1 print c for each (c, u)  E if (a.mark != 1) dfs (a) dfs(“a”) .... dfs(“c”) .... u=a a b d e c a · b · c · d · e · EE 5301 - VLSI Design Automation I

  18. d a c d d b a e b a b · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( c ) c.marked  1 print c for each (c, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... dfs(“c”) .... a b d e c a · b · c · d · e · EE 5301 - VLSI Design Automation I

  19. d d a c b e b b a a d · · · · · · · · · · · a e d b c Depth-First Search Algorithm dfs ( a ) a.marked  1 print a for each (a, u)  E if (u.mark != 1) dfs (u) dfs(“a”) .... a b d e c a · b · c · d · e · EE 5301 - VLSI Design Automation I

  20. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10   16 13 6 9   v6 v7 7 11 17   v2 v4 14 5  Edges examined v3 EE 5301 - VLSI Design Automation I

  21. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10  8 16 13 6 9   v6 v7 7 11 17 13 16 v2 v4 14 5   updated, min picked v3 EE 5301 - VLSI Design Automation I

  22. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10  8 16 13 6 9   v6 v7 7 11 17 13 16 v2 v4 14 5  S Augmented v3 EE 5301 - VLSI Design Automation I

  23. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10  8 16 13 6 9   v6 v7 7 11 17 13 16 v2 v4 14 5  Edges examined v3 EE 5301 - VLSI Design Automation I

  24. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25  updated, min picked v3 EE 5301 - VLSI Design Automation I

  25. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25 S Augmented v3 EE 5301 - VLSI Design Automation I

  26. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25 Edges examined v3 EE 5301 - VLSI Design Automation I

  27. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25  updated, min picked v3 EE 5301 - VLSI Design Automation I

  28. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25 S augmented v3 EE 5301 - VLSI Design Automation I

  29. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 25 Edges examined v3 EE 5301 - VLSI Design Automation I

  30. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 20  updated, min picked v3 EE 5301 - VLSI Design Automation I

  31. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 20 S augmented v3 EE 5301 - VLSI Design Automation I

  32. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 20 Edges examined v3 EE 5301 - VLSI Design Automation I

  33. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 20  updated, min picked v3 EE 5301 - VLSI Design Automation I

  34. Dijkstra’s Algorithm - an example u0 0 8 v5 v1 10 18 8 16 13 6 9   v6 v7 7 11 17 13 15 v2 v4 14 5 20 S augmented v3 EE 5301 - VLSI Design Automation I

  35. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1} Node v1 v2 v3 v4 v5  - 2 4 3   - v1 v1v1- EE 5301 - VLSI Design Automation I

  36. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1} Node v1v2 v3 v4 v5  - 2 4 3   - v1 v1v1 - EE 5301 - VLSI Design Automation I

  37. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2} Node v1 v2 v3 v4 v5  - 2 4 3   - v1 v1v1 - EE 5301 - VLSI Design Automation I

  38. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2} Node v1 v2 v3 v4 v5  - 2 1 25  - v1v2v2 v2 EE 5301 - VLSI Design Automation I

  39. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2} Node v1 v2v3 v4 v5  - 21 25  - v1 v2v2 v2 EE 5301 - VLSI Design Automation I

  40. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3} Node v1 v2v3 v4 v5  - 21 2 5  - v1 v2v2 v2 EE 5301 - VLSI Design Automation I

  41. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3} Node v1 v2v3 v4 v5  - 21 12  - v1 v2v3v3 EE 5301 - VLSI Design Automation I

  42. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3} Node v1 v2v3v4 v5  - 2112  - v1 v2v3 v3 EE 5301 - VLSI Design Automation I

  43. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3, v4} Node v1 v2v3v4 v5  - 211 2  - v1 v2v3 v3 EE 5301 - VLSI Design Automation I

  44. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3, v4} Node v1 v2v3v4 v5  - 211 2  - v1 v2v3 v3 EE 5301 - VLSI Design Automation I

  45. Prim’s Algorithm Example 2 v2 1 5 2 v3 4 2 v5 v1 3 1 3 v4 S = {v1, v2, v3, v4, v5} Node v1 v2v3v4v5  - 211 2  - v1 v2v3 v3 EE 5301 - VLSI Design Automation I

More Related