{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# graphs - CS 70 Fall 2006 Graphs Discrete Mathematics for CS...

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

CS 70 Discrete Mathematics for CS Fall 2006 Papadimitriou & Vazirani Lecture 16 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 V and a set of (directed) edges or arcs 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, such that ( u , v ) E ( v , u ) E . Thus, since the directions of the edges are unimportant, an undirected graph G ( V , E ) consists of a finite set of vertices V , and a set of edges E , each of which is an unordered pair of vertices { u , v } . As we have defined them, graphs are allowed to have self-loops; i.e. edges of the form ( u , u ) that go from a vertex to itself. Sometimes it is more convenient to disallow such self-loops. Graphs are useful for modeling a diverse number of 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 edges would be directed (a certain airline might have a non-stop flight from SFO to LAX, but no non-stop flight back from LAX to SFO). 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.

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.

{[ snackBarMessage ]}