1 / 36

Minimum Spanning Tree

Clayton Andrews COT4810 1/31/08. Minimum Spanning Tree. Firstly, a graph. A graph is a series of nodes connected with edges. Types of Graphs. Connected All nodes can be reached by all other nodes by following some series of edges All nodes are reachable from all other nodes Disconnected

gari
Download Presentation

Minimum Spanning Tree

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. Clayton Andrews COT4810 1/31/08 Minimum Spanning Tree

  2. Firstly, a graph • A graph is a series of nodes connected with edges.

  3. Types of Graphs • Connected • All nodes can be reached by all other nodes by following some series of edges • All nodes are reachable from all other nodes • Disconnected • There exists a node that is not reachable from some other node by any series of edges • One or more nodes are not reachable from one or more other nodes

  4. Types of Edges A B • Undirected • An edge goes to and from a node • An edge can be taken both directions • Edges show connections • Directed • Edges can specifically go to or from nodes • Edges can still be bidirectional • Edges can show a one way trip, visibility, etc.. C A B C

  5. Types of Edges 2 • Unweighted • Edges have no values • Edges just show some sort of connection • These edges can show neighbours, possible paths, etc.. • Weighted • Edges have a value attached to them • These values could be distance, cost, time, etc...

  6. What is a spanning tree? • A spanning tree is a sub-graph of another graph that connects all the nodes of the graph without forming a cycle(a loop) • The graph must be connected and be undirected

  7. What is a minimum spanning tree? • If a graph has weights for its edges, than a minimum spanning tree is the spanning tree that gives the lowest total sum of the edges. • Basically, it connects all of the nodes together for the least total weight

  8. Why should we care? • Why would anyone want to care about these trees that connect a series of nodes together? • A minimum spanning tree can be used for several things: • Identifying Clusters • Determining a central point of operations

  9. For Example: • Determining the location of roads • Where they should be placed • What cities they should pass through

  10. For Example: • Railroad Tracks • Where is a good central hub • What would cost us the least and be the quickest

  11. For Example: • Airports and Flight paths • Where airports should be • What path a flight should take

  12. Finding a minimum spanning tree • There are several ways to find a minimum spanning tree, but I am going to discuss the two most common methods • Prim's algorithmKruskal's algorithm

  13. Prim's Algorithm • Prim's Algorithm starts by making a set with a single node inside • It then looks for the shortest edge that does not form a cycle and adds its node to a set • It keeps going until all nodes are consumed

  14. Prim's Algorithm • Step 1: Pick an arbitrary starting node and put it into an empty set, X • Step 2: Look at the shortest edge coming from the set X • Step 3: Add the edge and add the node to the set • Step 4: Remove all edges that connect the set to itself • Step 5: If all nodes have not been added to set X, then repeat Steps 2 - 4 until all nodes have been added to the set X

  15. I chose D as my starting point

  16. The edge to A was the shortestfrom {D} so I added it to the set

  17. From the set {A, D}the edge to F is shortest

  18. The edge to B was the shortest edge from the set {A, D, F} so I added B to the set. The edge BD connects the set to itself, so it was removed

  19. From the set {A, B, D, F} the edge to E is the shortest. E is added to the set and two edges are removed

  20. From the set {A, B, D, E, F} the edge to C is the shortest. So, C is added to the set and an edge is removed

  21. Finally, from the set {A, B, C, D, E, F} the edge to G is the shortest so add G and remove an edge

  22. Now since all nodes are in the set, this is a minimum spanning tree

  23. Kruskal's Algorithm • Kruskal's algorithm works by selecting the shortest edges and adds them if they do not form a cycle • If an edge forms a cycle, it removes it from the list of edges and keeps going • It keeps going as long as all edges have not been considered

  24. Kruskal's Algorithm • Step 1: Put every node into a set by itself • Step 2: Choose the shortest edge that connects two of these sets, and merge these two sets into one • Step 3: Remove all edges that connect the set to itself • Step 4: If all edges have not been removed repeat steps 2 & 3 until there are no more remaining edges

  25. All nodes are now a set{A}, {B}, {C}, {D}, {F}, {G}

  26. The edge from set {A} to set {D} is tied for shortest with the edge from {C} to {E}, so just choose one, I chose {A} {D} to make {A, D}

  27. Now the edge from {C} to {E} is the shortest, so they combine to become {C, E}

  28. The shortest edge is now from {A, D} to {F} so they combine to become {A, D, F}

  29. The shortest edge is from {A, D, F} to {B} so combine to {A, B, D, F}. The edge from B to D connects the set to itself, it is removed

  30. The shortest edge is from{A, B, D, F} to {C, E} so combine and remove the three edges that connect the new set to itself

  31. Finally, the smallest edge is the edge to G from {A,B,C,D,E,F}, so combine these two sets and remove the edge that connects the new set to itself

  32. Since all edges have been added or removed, there are no more edges to consider, this is a minimum spanning tree.

  33. Both are fine • Both algorithms have the same time complexity, so it is usually up to the programmer to decide • Multiple minimum spanning trees can exist for a given graph, so these algorithms may produce different results for the same graph

  34. Summary • Minimum Spanning Trees are an efficient way to connect all of the nodes of a graph • They have several real world applications • There are 2 very common, very straight-forward solutions

  35. References • Wikipedia(www.wikipedia.com)‏ • All graph images • All minimum spanning tree images • Information related to minimum spanning tree • http://citeseer.ist.psu.edu/nesetril00otakar.html • Information related to algorithms • http://www.mapsofworld.com/ • Map of Florida Railroads • http://www.this-town.com/ • Map of Florida Highways • http://www.airchive.com/ • Map of Airline Flight Paths

  36. Homework • Name 2 algorithms used to find the minimum spanning tree of a graph. • What is another real world example of a use of a minimum spanning tree?

More Related