lecture16

# lecture16 - Introduction to Algorithms...

This preview shows pages 1–8. Sign up to view the full content.

Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 16 Prof. Charles E. Leiserson

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Algorithms Day 27 L16.2 © 2001 by Charles E. Leiserson Graphs (review) Definition. A directed graph ( digraph ) G = ( V , E ) is an ordered pair consisting of a set V of vertices (singular: vertex ), a set E V × V of edges . In an undirected graph G = ( V , E ) , the edge set E consists of unordered pairs of vertices. In either case, we have | E | = O ( V 2 ) . Moreover, if G is connected, then | E | | V | –1 , which implies that lg | E | = Θ (lg V ) . (Review CLRS, Appendix B.)
Introduction to Algorithms Day 27 L16.3 © 2001 by Charles E. Leiserson Adjacency-matrix representation The adjacency matrix of a graph G = ( V , E ) , where V = {1, 2, …, n } , is the matrix A [1 . . n , 1 . . n ] given by A [ i , j ] = 1 if ( i , j ) E , 0 if ( i , j ) E . 2 2 1 1 3 3 4 4 A 1234 1 2 3 4 0110 0010 0000 Θ ( V 2 ) storage dense representation.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Algorithms Day 27 L16.5 © 2001 by Charles E. Leiserson Minimum spanning trees Input: A connected, undirected graph G = ( V , E ) with weight function w : E R . For simplicity, assume that all edge weights are distinct. (CLRS covers the general case.) = T v u v u w T w ) , ( ) , ( ) ( . Output: A spanning tree T — a tree that connects all vertices — of minimum weight:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Algorithms Day 27 L16.6 © 2001 by Charles E. Leiserson Example of MST 61 2 5 14 3 8 10 15 9 7
Introduction to Algorithms Day 27 L16.7 © 2001 by Charles E. Leiserson u v Remove any edge ( u , v ) T . Then, T is partitioned into two subtrees T 1 and T 2 . T 1 T 2 Optimal substructure MST T : (Other edges of G are not shown.) Theorem. The subtree T 1 is an MST of G 1 = ( V 1 , E 1 ) , the subgraph of G induced by the vertices of T 1 : V 1 = vertices of T 1 , E 1 = { ( x , y ) E : x , y V 1 } .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/09/2009 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

### Page1 / 30

lecture16 - Introduction to Algorithms...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online