The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Lecture 17 - minimum spanning trees Select an arbitrary vertex to start. While (there are non-tree vertices) select minimum weight edge between tree and fringe add the selected edge and vertex to the tree This can be done in O(n m) time, by doing a DFS or BFS to loop through all edges, with a constant time test per edge, and a total of n iterations. Can we do faster? If so, we need to be able to identify fringe vertices and the minimum cost edge associated with it, fast. We will augment an adjacency list with fields maintaining fringe information. Vertex: fringelink pointer to next vertex in fringe list. fringe weight cheapest edge linking v to l. parent other vertex with v having fringeweight. status intree, fringe, unseen. adjacency list the list of edges. Listen To Part 18-8 Finding the minimum weight fringe-edge takes O(n) time - just bump through fringe list. After adding a vertex to the tree, running through its adjacency list to update the cost of adding fringe vertices (there may be a cheaper way through the new vertex) can be done in O(n) time. Total time is . Listen To Part 18-9 file:///E|/LEC/LECTUR16/NODE17.HTM (5 of 11) [19/1/2003 1:35:14] Kruskal's Algorithm
Lecture 17 - minimum spanning trees Since an easy lower bound argument shows that every edge must be looked at to find the minimum spanning tree, and the number of edges , Prim's algorithm is optimal in the worst case. Is that all she wrote? The complexity of Prim's algorithm is independent of the number of edges. Can we do better with sparse graphs? Yes! Kruskal's algorithm is also greedy. It repeatedly adds the smallest edge to the spanning tree that does not create a cycle. Obviously, this gives a spanning tree, but is it minimal? Listen To Part 18-10 Why is Kruskal's algorithm correct? Theorem: Let G be a weighted graph and let . If E' is contained in a MST T and e is the smallest edge in E-E' which does not create a cycle, . Proof: As before, suppose e is not in T. Adding e to T makes a cycle. Deleting another edge from this cycle leaves a connected graph, and if it is one from E-E' the cost of this tree goes down. Since such an edge exists, T could not be a MST. Listen To Part 18-11 What is the simplest implementation? ● Sort the m edges in time. How fast is Kruskal's algorithm? ● For each edge in order, test whether it creates a cycle the forest we have thus far built - if so discard, else add to forest. With a BFS/DFS, this can be done in O(n) time (since the tree has at most n edges). file:///E|/LEC/LECTUR16/NODE17.HTM (6 of 11) [19/1/2003 1:35:14]
- Page 941 and 942: Lecture 11 - backtracking Only 63 s
- Page 943 and 944: Lecture 11 - backtracking Recursion
- Page 945 and 946: Lecture 11 - backtracking Specifica
- Page 947 and 948: Lecture 12 - introduction to dynami
- Page 949 and 950: Lecture 12 - introduction to dynami
- Page 951 and 952: Lecture 12 - introduction to dynami
- Page 953 and 954: Lecture 12 - introduction to dynami
- Page 955 and 956: Lecture 12 - introduction to dynami
- Page 957 and 958: Lecture 13 - dynamic programming ap
- Page 959 and 960: Lecture 13 - dynamic programming ap
- Page 961 and 962: Lecture 13 - dynamic programming ap
- Page 963 and 964: Lecture 14 - data structures for gr
- Page 965 and 966: Lecture 14 - data structures for gr
- Page 967 and 968: Lecture 14 - data structures for gr
- Page 969 and 970: Lecture 14 - data structures for gr
- Page 971 and 972: Lecture 14 - data structures for gr
- Page 973 and 974: Lecture 14 - data structures for gr
- Page 975 and 976: Lecture 15 - DFS and BFS Next: Lect
- Page 977 and 978: Lecture 15 - DFS and BFS In a DFS o
- Page 979 and 980: Lecture 15 - DFS and BFS It could u
- Page 981 and 982: Lecture 15 - DFS and BFS Algorithm
- Page 983 and 984: Lecture 16 - applications of DFS an
- Page 985 and 986: Lecture 16 - applications of DFS an
- Page 987 and 988: Lecture 16 - applications of DFS an
- Page 989 and 990: Lecture 17 - minimum spanning trees
- Page 991: Lecture 17 - minimum spanning trees
- Page 995 and 996: Lecture 17 - minimum spanning trees
- Page 997 and 998: Lecture 17 - minimum spanning trees
- Page 999 and 1000: Lecture 18 - shortest path algorthm
- Page 1001 and 1002: Lecture 18 - shortest path algorthm
- Page 1003 and 1004: Lecture 18 - shortest path algorthm
- Page 1005 and 1006: Lecture 18 - shortest path algorthm
- Page 1007 and 1008: Lecture 18 - shortest path algorthm
- Page 1009 and 1010: Lecture 19 - satisfiability Next: L
- Page 1011 and 1012: Lecture 19 - satisfiability Why? Th
- Page 1013 and 1014: Lecture 19 - satisfiability between
- Page 1015 and 1016: Lecture 19 - satisfiability Note th
- Page 1017 and 1018: Lecture 20 - integer programming Ex
- Page 1019 and 1020: Lecture 20 - integer programming Ne
- Page 1021 and 1022: Lecture 21 - vertex cover Proof: VC
- Page 1023 and 1024: Lecture 21 - vertex cover Question:
- Page 1025 and 1026: Lecture 21 - vertex cover seen to d
- Page 1027 and 1028: Lecture 22 - techniques for proving
- Page 1029 and 1030: Lecture 22 - techniques for proving
- Page 1031 and 1032: Lecture 22 - techniques for proving
- Page 1033 and 1034: Lecture 22 - techniques for proving
- Page 1035 and 1036: Lecture 23 - approximation algorith
- Page 1037 and 1038: Lecture 23 - approximation algorith
- Page 1039 and 1040: Lecture 23 - approximation algorith
- Page 1041 and 1042: Lecture 23 - approximation algorith
Lecture 17 - minimum spanning trees<br />
Select an arbitrary vertex to start.<br />
While (there are non-tree vertices)<br />
select minimum weight edge between tree and fringe<br />
add the selected edge and vertex to the tree<br />
This can be done in O(n m) time, by doing a DFS or BFS to loop through all edges, with a constant time<br />
test per edge, and a total of n iterations.<br />
Can we do faster? If so, we need to be able to identify fringe vertices and the minimum cost edge<br />
associated with it, fast. We will augment an adjacency list with fields maintaining fringe information.<br />
Vertex:<br />
fringelink pointer to next vertex in fringe list.<br />
fringe weight cheapest edge linking v to l.<br />
parent other vertex with v having fringeweight.<br />
status intree, fringe, unseen.<br />
adjacency list the list of edges.<br />
Listen To Part 18-8<br />
Finding the minimum weight fringe-edge takes O(n) time - just bump through fringe list.<br />
After adding a vertex to the tree, running through its adjacency list to update the cost of adding fringe<br />
vertices (there may be a cheaper way through the new vertex) can be done in O(n) time.<br />
Total time is .<br />
Listen To Part 18-9<br />
file:///E|/LEC/LECTUR16/NODE17.HTM (5 of 11) [19/1/2003 1:35:14]<br />
Kruskal's <strong>Algorithm</strong>