apr9-14 - Illinois Institute of Technology Department of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Illinois Institute of Technology Department of Computer Science Lectures 19–20: April 9–14 CS 330 Discrete Mathematics Spring Semester, 2008 1 Graph theory 1.1 Terminology A graph G is defined as a pair ( V, E ), where V is a set of vertices and E is a set of edges . A vertex can be thought of as a point and an edge as a line connecting the two points. (The problem we considered earlier in the lecture could be more precisely considered in graph theoretic terms.) An edge e ∈ E is typically represented as a pair ( u, v ) where the edge is from u to v , where u, v ∈ V . Graphs are simple structures with many useful applications. Depending on the application slight variations on the structure are useful. For instance, graphs can be directed or undirected . In a directed graph edges are unidirectional: for instance, an edge e might be from v 1 to v 2 but not from v 2 to v 1 . A directed graph could model, say, the water pipes in a building or the network of (potentially one-way) roads in a city. In an undirected graph edges are bidirectional: an edge e might connect v 1 with v 2 in both directions. An undirected graph could model, for instance, the network of walkways around campus. 1 Each edge in a graph may also have an associated weight . The weight on an edge could represent the capacity of a pipe or of a road. In rare cases, it is useful to associate weights with vertices rather than (or as well as) edges: for instance, the capacity through a pipe connector or of a road intersection. Questions about graphs can be of a structural or of an algorithmic nature. Given a graph, a structural question would be whether it can be drawn with no crossing edges. 2 A related algorithmic question would be how to draw the graph with the fewest crossing edges. In this course we will be most concerned with algorithmic questions. 1.2 Representations While a graph has a simple mathematical definition, we have yet to examine representations of graphs that are algorithmically useful. Three representations are presented here, adjacency structures (or adjacency lists), adjacency matrices, and incidence matrices. 1.2.1 Adjacency structures The adjacency structure or adjacency list representation of a graph G = ( V, E ) is an array of | V | lists, one for each vertex in V . The list corresponding to the vertex v i consists of the vertices in V that have edges from v i . An adjacency structure requires O ( | V | + | E | ) space. 1 Note that an undirected graph can be defined in terms of a directed graph: if ( u,v ) ∈ E , then ( v, u ) ∈ E as well. 2 Such a graph is termed a planar graph. CS 330—Spring, 2008 2 Lectures 19–20: April 9–14 1.2.2 Adjacency matrices The adjacency matrix corresponding to a graph G = ( V, E ), where V = v 1 , v 2 , . . . , v | V | , is a | V |×| V | binary matrix A defined by: A ij = ½ 1 if ( v i , v j ) ∈ E 0 otherwise An adjacency matrix requires | V | 2 bits of space....
View Full Document

This note was uploaded on 04/15/2008 for the course CS 330 taught by Professor Reingold,edwardm. during the Spring '08 term at Illinois Tech.

Page1 / 6

apr9-14 - Illinois Institute of Technology Department of...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online