===============================================================
Lect 20 - December 4, 2008 - ECS 20 - Fall 2008 - Phil Rogaway
===============================================================
Today: o Students evaluate Me // 20 mins
Tung (your TA)
Min-Eu (your grader)
o Graph theory
o Hints for the final, Goodbye!
Announcements
- Review session 4-5:30 in Chem 166
Please work out practice-exam first -- it's on the web
----------------------------------------------------------------------------
Graph theory
----------------------------------------------------------------------------
1. Notion of a graph
....................
Def: A (finite, simple) Graph G=(V,E) is an ordered pair
- where V is a nonempty finite set (the "vertices" or "nodes")
- where E is a collection of two-elements subsets of V (the "edges")
Conventional representation: picture.
Be clear: the picture is NOT the graph, it is a representation of the graph.
B--- C
/ \ /
A D
B--- D
/ \ /
A C
are the SAME graph.
Def: Two vertices v, w of a graph G=(V,E) are _adjacent_ if {v,w} in E.
Def: The _degree_ of a vertex d(v) = |{v,w}: w\in V|
I like {x,y} for an edge, emphasizing that {x,y} are unordered.
Will sometimes see xy or (x,y), but both "look" like the order matters, which it does not.
Usually write n=|V|, m=|E|
2. Paths in graphs
..................
Def: A _path_ P=(v_1, ..., v_n) in G=(V,E) is a sequence of vertices s.t. {v_i,v_{i+1}}\in E
for all i in {1,..., n-1}.
A path is said to _contain_ the vertices and to _contain_ the edges {v_i,v_{i+1}.
The _length_ of a path is the number of edges on it.
A _cycle_ is a path of length 3 or more that starts and stops at the same vertex and
includes no repeated vertices apart from the first vertex being the last.
//revised from the definition I first gave in lecture
A graph is _acyclic_ if it contains no cycle.
A graph G=(V,E) is _connected_ if, for all x,y in V, there is a path from x to y.
3. Trees
........
Def: A _tree_ is a connected acyclic graph.
Proposition: A connected graph is tree iff |E|= |V|-1
Proof: By induction ....
4. Eulerian and Hamiltonian graphs
..................................
Def: A graph G is _Eulerian_ if it there is a cycle C in G that goes through every
edge exactly once.
A graph G is _Hamiltonian_ if there is a cycle that goes through every vertex
exactly once.
Theorem: (Euler) A connected graph G=(V,E) on \ge 3 vertices is Eulerian
iff
every vertex of G is of even degree.
Proof: --> Choose s. Graph is Eulerian mean there is a path that starts at
s and eventually ends at s, hitting every edge. Put a label of 0 on
every vertex. Now, follow the path. Every time we exit a vertex, increment
the label. Every time we enter a vertex, increment the label.
At end of traversing the graph, label(v) = degree(v) and this is even.
<-- (sketch) If every vertex is of even degree, at least three vertices. Start at s
and grow a cycle C of unexplored edges until you wind up back at s.
You never "get stuck" by even-degree constraint. If every edge explored:
Done. Otherwise, find contact point of C and an unexplored edge (exists
by connectedness) and grow out from there. Splice together the paths.
So there is a trivial algorithm to decide if G is Eulerian: just check if all its
vertices are of even degree.
Amazing fact: There is no reasonable algorithm known to decide if a graph is Hamiltonian.
(Most computer scientists believe that no such algorithm exists.)
5. Longest and shortest paths
.............................
Def: A _shortest path_ between two vertices x and y is a path from x to y such that there
is no shorter (=fewer edges) path from x to y.
A _longest path_ between two vertices x and y is a _simple path_ (=no repeated
vertices) from x to y.
Claim: There is an efficient algorithm to identify a shortest path between two designated
vertices in a graph.
(You will learn one in ecs122A and maybe ecs60)
Amazing fact: There is no efficient algorithm known to find a longest path from x to y.
(Most computer scientists believe that no such algorithm exists.)
6. Colorability
...............
Def: A graph G = (V,E) is *k-colorable* if we can paint the vertices using "colors"
{1,...,k} such that no adjacent vertices have the same color.
Def: A graph is bipartite if it is 2-colorable. In other words, we can partition
V into (V1, V2) such that all edges go between a vertex in V1 and a vertex in V2.
Proposition: There is a simple and efficient algorithm to decide if a graph G is 2-colorable.
Proofs: Modify DFS. Or show ad hoc algorithm directly...
Amazing fact: There is no reasonable algorithm known to decide if a graph is 3-colorable.
(Most computer scientists believe that no such algorithm exists.)
7. Planar graphs (not done in lecture)
.......................................
Def: A graph is *planar* if you can draw it in the plane with no crossing edges.
Amazing fact: there is a simple algorithm to decide if a graph is planar
(and, when it is, to find an embedding)
8. Isomorphic graphs
....................
Def: Graphs G=(V,E) and G'=(V',E') are ISOMORPHIC if there exists a bijection
pi: V -> V' s.t. {x,y} in E iff {pi(x),pi(y)} in E.
Amazing fact: there is no efficient algorithm known to decide if two graphs
are isomorphic. (Most computer scientists believe that no such algorithm
exists.)
----------------------------------------------------------------------------
Hints for Final, Goodbye
----------------------------------------------------------------------------
- It will probably look like the midterm in structure (I haven't yet written the
exam).
- Learn the things that have been asked and answered already: problem sets and
their solutions / quizzes / midterm / practice exams. I do like to make sure
that I repeat some questions with little or no change: this is a way to reward
students who didn't get it before but put in the time to get it now, and a way
to deal with the fact that sometimes very clever students are not "fast" enough
to solve something highly unfamiliar, and being "fast" is not what I aim to grade.
- Some of you are freshman, so I'll give you my sage advice on studying for
this or most other exams: Don't spend too much time doing so, as it's stressful
and rarely helps. Instead, you really have to be learning the material well
throughout the term. Education is a marathon, not a sprint.
I myself was always too stressed out to study during finals week; frightened
by exams, I couldn't eat the day of an exam, and I couldn't really learn much
new in the days before. Catching a film is good. So is getting some sleep.
GOOD LUCK and HAPPY TO HAVE MET YOU
phil rogaway