04/05/09
01:54:57
1
28
CS 61B:
Lecture 28
Friday, April 3, 2009
GRAPHS
======
A graph G is a set V of vertices (sometimes called nodes), and a set E of edges
(sometimes called arcs) that each connect two vertices together.
To confuse
you, mathematicians often use the notation G = (V, E).
Here, "(V, E)" is an
_ordered_pair_ of sets.
This isn’t as deep and meaningful as it sounds;
some people just love formalism.
The notation is convenient when you want to
discuss several graphs with the same vertices; e.g. G = (V, E) and T = (V, F).
Graphs come in two types:
_directed_ and _undirected_.
In a directed graph
(or _digraph_ for short), every edge e is directed from some vertex v to some
vertex w.
We write "e = (v, w)" (also an ordered pair), and draw an arrow
pointing from v to w.
The vertex v is called the _origin_ of e, and w is the
_destination_ of e.
In an undirected graph, edges have no favored direction, so we draw a curve
connecting v and w.
We still write e = (v, w), but now it’s an unordered pair,
which means that (v, w) = (w, v).
One application of a graph is to model a street map.
For each intersection,
define a vertex that represents it.
If two intersections are connected by a
length of street with no intervening intersection, define an edge connecting
them.
We might use an undirected graph, but if there are oneway streets, a
directed graph is more appropriate.
We can model a twoway street with two
edges, one pointing in each direction.
On the other hand, if we want a graph
that tells us which cities adjoin each other, an undirected graph makes sense.

Bancroft




1<2<3
AlbanyKensington






^
 ^
\
/
Dana 
Telegraph 
Bowditch  


v

v 
EmeryvilleBerkeley





4>5>6
\
/

Durant




OaklandPiedmont
Multiple copies of an edge are forbidden,


but a directed graph may contain both (v, w)
and (w, v).
Both types of graph can have _selfedges_ of the form (v, v),
which connect a vertex to itself.
(Many applications, like the two illustrated
above, don’t use these.)
A _path_ is a sequence of vertices such that each adjacent pair of vertices is
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.
 Spring '01
 Canny
 Graph Theory, Data Structures, Vertex, Emeryville

Click to edit the document details