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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

⎧<br />

⎪⎨<br />

We represented the maze as a graph for clarity.<br />

⎪⎩<br />

〈a, e〉, 〈e, i〉, 〈i, j〉,<br />

〈f, j〉, 〈f, g〉, 〈g, h〉,<br />

〈d, h〉, 〈g, k〉, 〈a, b〉<br />

〈m, n〉, 〈n, o〉, 〈b, c〉<br />

〈k, o〉, 〈o, p〉, 〈l, p〉<br />

Now, we are interested in circuits, which we will also represent as graphs.<br />

⎫<br />

⎪⎬<br />

<br />

, a, p<br />

Let us look at the theory of graphs first (so we know what we are doing)<br />

c○: Michael Kohlhase 213<br />

Graphs and trees are fundamental data structures for computer science, they will pop up in many<br />

disguises in almost all areas of CS. We have already seen various forms of trees: formula trees,<br />

tableaux, . . . . We will now look at their mathematical treatment, so that we are equipped to talk<br />

and think about combinatory circuits.<br />

We will first introduce the formal definitions of graphs (trees will turn out to be special graphs),<br />

and then fortify our intuition using some examples.<br />

Basic Definitions: Graphs<br />

Definition 360 An undirected graph is a pair 〈V, E〉 such that<br />

V is a set of vertices (or nodes) (draw as circles)<br />

E ⊆ {{v, v ′ } | v, v ′ ∈ V ∧ (v = v ′ )} is the set of its undirected edges (draw as lines)<br />

Definition 361 A directed graph (also called digraph) is a pair 〈V, E〉 such that<br />

V is a set of vertices<br />

E ⊆ V × V is the set of its directed edges<br />

Definition 362 Given a graph G = 〈V, E〉. The in-degree indeg(v) and the out-degree<br />

outdeg(v) of a vertex v ∈ V are defined as<br />

indeg(v) = #({w | 〈w, v〉 ∈ E})<br />

outdeg(v) = #({w | 〈v, w〉 ∈ E})<br />

Note: For an undirected graph, indeg(v) = outdeg(v) for all nodes v.<br />

c○: Michael Kohlhase 214<br />

We will mostly concentrate on directed graphs in the following, since they are most important for<br />

the applications we have in mind. Many of the notions can be defined for undirected graphs with<br />

a little imagination. For instance the definitions for indeg and outdeg are the obvious variants:<br />

indeg(v) = #({w | {w, v} ∈ E}) and outdeg(v) = #({w | {v, w} ∈ E})<br />

In the following if we do not specify that a graph is undirected, it will be assumed to be<br />

directed.<br />

This is a very abstract yet elementary definition. We only need very basic concepts like sets and<br />

ordered pairs to understand them. The main difference between directed and undirected graphs<br />

can be visualized in the graphic representations below:<br />

116<br />

⎪⎭

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

Saved successfully!

Ooh no, something went wrong!