{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

28 - 01:54:57 CS 61B Lecture 28 Friday April 3 2009 GRAPHS...

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

View Full Document Right Arrow Icon
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 one-way streets, a directed graph is more appropriate. We can model a two-way 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| |Albany|------|Kensington| --- --- --- -------- ------------ | ^ | ^ \ / Dana | Telegraph | Bowditch | | ------------ ---------- v | v | |Emeryville|-----|Berkeley| --- --- --- ------------ ---------- |4|------------>|5|------------>|6| \ / --- Durant --- --- --------- ---------- |Oakland|-----|Piedmont| 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 _self-edges_ 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
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

28 - 01:54:57 CS 61B Lecture 28 Friday April 3 2009 GRAPHS...

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

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