Lemma: The shortest walk between two vertices is a path!. Proof: by contradiction suppose path from u to v crossed itself: c Walks & Paths... Proof: by contradiction suppose path from u
Trang 1Directed Graphs
Trang 2Normal Person’s Graph
y
y = f(x)
Trang 3Computer Scientist’s Graph
a
f
e
c
d
b
Trang 4• a set, V, of vertices
aka “nodes”
• a set, E ⊆ V×V
of directed edges
(v,w) ∈ E
notation: v→w
Trang 5Relations and Graphs
a
c
b
d
V= {a,b,c,d}
E = {(a,b), (a,c), (c,b)}
Trang 6Formally, a digraph with vertices
V is the same as a binary relation
on V
Digraphs
Trang 7Walks & Paths
Walk : follow successive edges
length: 5 edges
( not the 6 vertices )
Trang 8Walks & Paths
Path : walk thru vertices without repeat vertex
length: 4 edges
Trang 9Lemma:
The shortest walk between two vertices is a path!
Proof: (by contradiction) suppose
path from u to v crossed itself:
c Walks & Paths
Trang 10Proof: (by contradiction) suppose path from u to v
crossed itself:
then path without c -c is
shorter !
Lemma:
The shortest walk between two vertices is a path!
Walks & Paths
Trang 11Walks & Paths
Digraph G defines walk
relation G+
u G+ v iff ∃walk u to v
(the positive walk relation)
“+” means 1 or more
Trang 12Walks & Paths
Digraph G defines walk
relation G*
u G* v iff u to v∃ walk
1 2 3
Trang 13A cycle is a walk whose
only repeat vertex is its
start & end
(a single vertex is a
length 0 cycle)
Trang 14v0
v0
vi
vi+1
Cycles
Trang 15Closed walk starts & ends at the
same vertex.
Lemma: The shortest positive
length closed walk containing a
vertex is a positive length cycle!
Proof: similar
Closed Walks & Cycles
Trang 16has no positive length cycle
D irected A cyclic G raph
DAG
Trang 17< relation on integers
⊊ relation on sets
prerequisite on classes
D irected A cyclic G raph
DAG
Trang 18Example: Tournament Graph
• Every team plays every other
H