1 / 26

Minimum Spanning Trees and Shortest Paths in Graphs: Algorithms, Examples, and Applications

This text discusses the concepts of minimum spanning trees and shortest paths in graphs, and presents algorithms such as Kruskal's and Dijkstra's for solving these problems. It also explores the applications of these algorithms in various scenarios.

janat
Download Presentation

Minimum Spanning Trees and Shortest Paths in Graphs: Algorithms, Examples, and Applications

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. Discrete Structures & AlgorithmsGraphs and Trees: III EECE 320

  2. 7 8 4 5 9 7 9 8 6 11 Reminder: Spanning Trees A spanning tree of a graph G is a tree that touches every node of G and uses only edges from G Problem: Find a minimum spanning tree, that is, a tree that has a node for every node in the graph, such that the sum of the edge weights is minimum

  3. Finding a MST: Kruskal’s Algorithm Create a forest where each node is a separate tree Make a sorted list of edges S While S is non-empty: Remove an edge with minimal weight If it connects two different trees, add the edge. Otherwise discard it.

  4. Applying the Algorithm 7 4 1 5 9 8 10 9 7 3

  5. Greed is Good (In this case…) The greedy algorithm, by adding the least costly edges in each stage, succeeds in finding an MST Obviously greedy approaches do not work for all problems … Some examples where they do work?

  6. 7 4 1 5 9 8 10 9 7 Greedy Algorithms vs. Backtracking 3

  7. Shortest-paths in a graph

  8. Shortest path problem • Input data: • Directed graph: G= (V, E) • Start and end node: s, t • Length le for each edge e • Output: shortest path from s to t • [cost of path = sum of all edges]

  9. Dijkstra’s algorithm • Idea: Maintain a set of explored nodesS for which we have determined the shortest path distance d(u) from s to u.

  10. Dijkstra’s algorithm • Idea: Maintain a set of explored nodes S for which we have determined the shortest path distance d(u) from s to u. • Initialize S = {s}, d(s) = 0. • Repeatedly choose unexplored node v to minimize • add v to S, and set d(v) = π(v). • Until all nodes are chosen Shortest path from a node in u to any other unexplored node

  11. Example

  12. Dijkstra: Complexity analysis • Initialize S = {s}, d(s) = 0. • Repeatedly choose unexplored node v to minimize • add v to S, and set d(v) = π(v).

  13. Bipartite Graphs A graph is bipartite if the nodes can be partitioned into two sets V1 and V2 such that all edges go only between V1 and V2 (no edges go from V1 to V1 or from V2 to V2)

  14. Dancing Partners A group of 100 boys and girls attend a dance. Every boy knows 5 girls, and every girl knows 5 boys. Can they be matched into dance partners so that each pair knows each other?

  15. Dancing Partners

  16. Perfect Matchings Perfect Matching: A matching that covers all nodes in the graph with one edge going to each node. Theorem: If every node in a bipartite graph has the same degree d  1, then the graph has a perfect matching. Note: if degrees are the same then |A| = |B|, where A is the set of nodes “on the left” and B is the set of nodes “on the right”

  17. A Matter of Degree Claim: If all nodes have the same degree then |A| = |B| Proof: If there are m boys, there are md edges If there are n girls, there are nd edges

  18. The Marriage Theorem • Theorem: A bipartite graph has a perfect matching if and only if • |A| = |B| • and • for all k  [1,n]: for any subset of k nodes of A there are at leastk nodes of B that are connected to at least one of them.

  19. The Marriage Theorem For any subset of (say) k nodes of A there are at least k nodes of B that are connected to at least one of them The condition fails for this graph

  20. The Feeling is Mutual At least k k At most n-k n-k The condition of the theorem still holds if we swap the roles of A and B: If we pick any k nodes in B, they are connected to at least k nodes in A

  21. Proof Sketch of Marriage Theorem Call a bipartite graph “matchable” if it has the same number of nodes on left and right, and any k nodes on the left are connected to at least k on the right Strategy: Break up the graph into two matchable parts, and recursively partition each of these into two matchable parts, etc., until each part has only two nodes

  22. Proof Sketch of Marriage Theorem Select two nodes a  A and b  B connected by an edge Idea: Take G1 = (a,b) and G2 = everything else Problem: G2 need not be matchable. There could be a set of k nodes that has only k-1 neighbors.

  23. Sketch of Marriage Theorem Proof The only way this could fail is if one of the missing nodes is b a b k-1 k Add this in to form G1, and take G2 to be everything else. This is a matchable partition!

  24. More formally …

  25. Minimum Spanning Tree - Definition Kruskal’s Algorithm - Definition - Proof of Correctness Dijkstra’s algorithm - algorithm - proof of correctness The Marriage Theorem Here’s What You Need to Know…

More Related