15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Paths in Graphs<br />

Definition 373 Given a directed graph G = 〈V, E〉, then we call a vector p = 〈v0, . . . , vn〉 ∈<br />

V n+1 a path in G iff 〈vi−1, vi〉 ∈ E for all (1 ≤ i ≤ n), n > 0.<br />

v0 is called the start of p (write start(p))<br />

vn is called the end of p (write end(p))<br />

n is called the length of p (write len(p))<br />

Note: Not all vi-s in a path are necessarily different.<br />

Notation 374 For a graph G = 〈V, E〉 and a path p = 〈v0, . . . , vn〉 ∈ V n+1 , write<br />

v ∈ p, iff v ∈ V is a vertex on the path (∃i.vi = v)<br />

e ∈ p, iff e = 〈v, v ′ 〉 ∈ E is an edge on the path (∃i.vi = v ∧ vi+1 = v ′ )<br />

Notation 375 We write Π(G) for the set of all paths in a graph G.<br />

c○: Michael Kohlhase 220<br />

An important special case of a path is one that starts and ends in the same node. We call it a<br />

cycle. The problem with cyclic graphs is that they contain paths of infinite length, even if they<br />

have only a finite number of nodes.<br />

Cycles in Graphs<br />

Definition 376 Given a graph G = 〈V, E〉, then<br />

a path p is called cyclic (or a cycle) iff start(p) = end(p).<br />

a cycle 〈v0, . . . , vn〉 is called simple, iff vi = vj for 1 ≤ i, j ≤ n with i = j.<br />

graph G is called acyclic iff there is no cyclic path in G.<br />

Example 377 〈2, 4, 3〉 and 〈2, 5, 6, 5, 6, 5〉 are paths in<br />

1<br />

2<br />

3<br />

〈2, 4, 3, 1, 2〉 is not a path (no edge from vertex 1 to vertex 2)<br />

The graph is not acyclic (〈5, 6, 5〉 is a cycle)<br />

Definition 378 We will sometimes use the abbreviation DAG for “directed acyclic graph”.<br />

c○: Michael Kohlhase 221<br />

Of course, speaking about cycles is only meaningful in directed graphs, since undirected graphs<br />

can only be acyclic, iff they do not have edges at all.<br />

Graph Depth<br />

Definition 379 Let G := 〈V, E〉 be a digraph, then the depth dp(v) of a vertex v ∈ V<br />

is defined to be 0, if v is a source of G and sup{len(p) | indeg(start(p)) = 0 ∧ end(p) = v}<br />

120<br />

5<br />

4<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!