algorithms
play

Algorithms R OBERT S EDGEWICK | K EVIN W AYNE 4.3 G REEDY MST D EMO - PowerPoint PPT Presentation

Algorithms R OBERT S EDGEWICK | K EVIN W AYNE 4.3 G REEDY MST D EMO Algorithms F O U R T H E D I T I O N R OBERT S EDGEWICK | K EVIN W AYNE http://algs4.cs.princeton.edu Greedy MST algorithm demo Start with all edges colored gray. Find


  1. Algorithms R OBERT S EDGEWICK | K EVIN W AYNE 4.3 G REEDY MST D EMO Algorithms F O U R T H E D I T I O N R OBERT S EDGEWICK | K EVIN W AYNE http://algs4.cs.princeton.edu

  2. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 0-7 0.16 2-3 0.17 1 1-7 0.19 3 0-2 0.26 5 5-7 0.28 7 1-3 0.29 2 1-5 0.32 0 2-7 0.34 4-5 0.35 1-2 0.36 6 4 4-7 0.37 0-4 0.38 an edge-weighted graph 6-2 0.40 3-6 0.52 6-0 0.58 6-4 0.93 2

  3. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges crossing edge (sorted by weight) 1 3 5 in MST 0-2 0.26 1-3 0.29 7 2 2-7 0.34 1-2 0.36 0 6-0 0.58 6-4 0.93 6 4 min-weight grey vertices form crossing edge one side of cut 3

  4. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 4

  5. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges (sorted by weight) 1 3 5 in MST 5-7 0.28 1-5 0.32 7 2 4-5 0.35 min-weight 0 crossing edge 6 4 MST edges 0-2 5

  6. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6

  7. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges (sorted by weight) 1 3 5 in MST 6-2 0.40 3-6 0.52 7 2 6-0 0.58 6-4 0.93 0 6 4 min-weight crossing edge MST edges 0-2 5-7 7

  8. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6-2 8

  9. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges (sorted by weight) 1 3 5 in MST 0-7 0.16 2-3 0.17 7 2 2-7 0.34 min-weight 4-5 0.35 0 crossing edge 1-2 0.36 4-7 0.37 6 4 3-6 0.52 MST edges 0-2 5-7 6-2 9

  10. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6-2 0-7 10

  11. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges min-weight (sorted by weight) crossing edge 1 3 5 in MST 2-3 0.17 1-7 0.19 7 2 1-5 0.32 1-2 0.36 0 6 4 MST edges 0-2 5-7 6-2 0-7 11

  12. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6-2 0-7 2-3 12

  13. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges (sorted by weight) 1 3 5 in MST 1-7 0.19 1-3 0.29 7 2 1-5 0.32 min-weight 4-5 0.35 0 crossing edge 1-2 0.36 4-7 0.37 6 4 0-4 0.38 6-4 0.93 MST edges 0-2 5-7 6-2 0-7 2-3 13

  14. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6-2 0-7 2-3 1-7 14

  15. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. crossing edges (sorted by weight) 1 3 5 in MST 4-5 0.35 4-7 0.37 7 2 0-4 0.38 min-weight 6-4 0.93 0 crossing edge 6 4 MST edges 0-2 5-7 6-2 0-7 2-3 1-7 15

  16. Greedy MST algorithm demo ・ Start with all edges colored gray. ・ Find cut with no black crossing edges; color its min-weight edge black. ・ Repeat until V - 1 edges are colored black. 1 3 5 7 2 0 6 4 MST edges 0-2 5-7 6-2 0-7 2-3 1-7 4-5 16

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