This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8 An Introduction to Graphs Formulating a simple, precise specification of a computational problem is often a prerequisite to writing a computer program for solving the problem. Many computational problems are best stated in terms of graphs : a directed graph G ( V , E ) consists of a finite set of vertices or nodes ) V and a set of (directed) edges E . An edge is an ordered pair of vertices ( v , w ) and is usually indicated by drawing a line between v and w , with an arrow pointing towards w . Undirected graphs may be regarded as special kinds of directed graphs, in which ( u , v ) E if and only if ( v , u ) E . Thus in an undirected graph the directions of the edges are unimportant, so an edge of an undirected graph is an unordered pair of vertices { u , v } and is indicated by a line between u and v with no arrow. More formally, the edge set of a directed graph is a subset E V V , where V V is the Cartesian product of V with itself. 1 As we have defined them, graphs are allowed to have selfloops ; i.e., edges of the form ( u , u ) or { u , u } that go from a vertex u to itself. Usually, however, graphs are assumed to have no selfloops unless otherwise stated, and we will assume this from now on. Graphs are useful for modeling many diverse situations. For example, the vertices of a graph might represent cities, and edges might represent highways that connect them. In this case, the edges would be undirected: In the above picture, V = { SF , LA , NY ,... } , and E = {{ SF , LA } , { SF , NY } ,... } . Alternatively, an edge might represent a flight from one city to another, and now the edges would be directed (since there may be a nonstop flight from SF to LA, but no nonstop flight back from LA to SF). Graphs can also be used to represent more abstract relationships. For example, the vertices of a graph might represent tasks, and the edges might represent precedence constraints: a directed edge from u to v says that task u must be completed before v can be started. An important problem in this context is scheduling : in what order should the tasks be scheduled so that all the precedence constraints are satisfied? A path in a directed graph G = ( V , E ) is a sequence of neighboring edges ( v 1 , v 2 ) , ( v 2 , v 3 ) ,..., ( v n 2 , v n 1 ) , ( v n 1 , v n ) . In this case we say that there is a path between v 1 and v n . A path in an undirected graph is defined similarly. A path is called simple if it has no repeated vertices. A cycle (or circuit ) is a path that begins and ends at the same vertex (i.e., it is a path from v to v for some v )....
View Full
Document
 Spring '08
 PAPADIMITROU

Click to edit the document details