Sie sind auf Seite 1von 17

DISCRETE MATHEMATICS

GRAPHS

Def
A graph G = (V, E) consists of a finite set V of vertices and a set E of
edges, such that each edge e E is associated with an unordered pair of
vertices. We write e = {v, w} = {w, v}. We assume v 6= w. We say v, w V
are adjacent vertices and that e is incident on v and w.

Ex.
V = {1, 3, 5, 7, 9} E = {{3, 7}, {5, 1}, {5, 9}, {1, 9}, {3, 5}}
Graphically:

3 5

7 9

Def. Complete Graphs.


The complete graph of n vertices, denoted by Kn , is the graph that con-
tains exactly one edge between each pair of distinct vertices,
Graphically:

K1 K2
K3 K4

Def. Subgraphs.
A graph G2 = (V2 , E2 ) is a subgraph of a graph G1 = (V1 , E1 ) iff V2 V1
and E2 E1 . If the edges of G1 connecting vertices of G2 are all in G2 , we say
G2 is a complete subgraph of G1 :

{x, y} E1 , x, y V2 = {x, y} E2

1
Ex.
1 1 1

0 2 0 2 0 2

4 3 3 3
G1 G2 G3

G2 is a subgraph of G1 but it is not a complete subgraph of G1 .


G3 is a complete subgraph of G1 .

Graph Representations
Two of the most common ways of representing graphs is as an adjacency list,
which consists of a list of vertices, where each vertex vi stores a list of all its
adjacent vertices vj .

Ex.
1

0 2

4 3
G1

0 1 2 3 4
1 0 2
The adjacent vertices to vertex 2 are vertices 0, 1 and 3.
2 0 1 3
3 0 2 4
4 3 0

Let G = (V, E) be a graph and let V = {v1 , v2 , . . . , vn }.


The adjacency matrix is the n n matrix M such that each entry

0 if there is no edge from vi to vj
M[i, j] =
1 if there is an edge from vi to vj

2
0 1 2 3 4

0 0 1 1 1 1
1 1
0 1 0 0
2 1
1 0 1 0 is the adjacency matrix of graph G1 . It is symmetric.
3 1 0 1 0 1
4 1 0 0 1 0

It is often useful to count the number of edges attached to a particular vertex.


We define deg(v), the degree of the vertex v, to be the number of edges
incident on v.

Theorem
The sum of the degrees of the vertices of a graph is twice the number of its
edges. X
deg(v) = 2 |E(G)|
vV (G)

Proof
Each edge contributes 2 to the degree sum.

Corollary
The number of vertices with an odd degree must be even.

Ex.
1

5 2

4 3
G1

deg(1)+deg(2)+deg(3)+deg(4)+deg(5) = 3+4+1+3+3 = 14 = 27 = 2|E|

Ex.
A certain company wants to build a network with its 5 computers, joining each
one to exactly three others. Is this possible?
The cities of a certain country are all connected to exactly three other cities.
Can this country have 50 roads? If they tell us it has 60 roads, how many cities
are there?
Can you draw 9 segments on a sheet of paper such that each one cuts exactly
three of the other segments? If you want to draw 6?

Def.
A graph is regular of degree r if every vertex has degree r.

3
Ex.
Kn is regular of degree n 1.

Def. Isomorphic Graphs.


It frequently happens that two graphs are essentially the same even though
they differ in the names of the edges and vertices. To make these ideas math-
ematically precise we introduce the concept of isomorphism.

Def.
Two graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are called isomorphic, written
G1 G2 , or that there is an isomrphism of one onto the other, if there
exists a bijection b : V1 V2 such that

x, y V1 , {x, y} E1 {b(x), b(y)} E2

a b

a b a c b d

c d c a d b

c d

G1 is isomorphic to G2 b() = = a, b, c, d, a , b , c , d is an
isomorphism.
It is not always easy to determine if two graphs are isomorphic, but if

Proposition

1. they have different number of vertices


or
2. they have different number of edges
or
3. they have different number of vertices of a certain degree n
or
4. if they differ in some other property preserved under isomorphisms, they
cannot be isomorphic.

4
Ex.
G1 6 G2
a 1

e b 0 2

d c 4 3
G1 G2

K4 is a subgraph of G1 .
K4 is not a subgraph of G2 .

G1 6 G2 because 1, 2 are two adjacent vertices of degree 3 and G2 has no two


adjacent vertices of degree 3.

1 2

G1 G2

Paths and Cycles


Frequently we use graphs as models of practical situations involving routes:
the vertices represent towns or junctions and each edge represents a road or
some other form of communication link.
The following definitions refer to sequences of vertices with interesting math-
ematical properties.

Def.
Let G = (V, E) be a graph.
A walk in G is a sequence of vertices v0 , . . . , vn such that vi and vi+1 are
adjacent for 0 i n 1. If all vertices are distinct, a walk is called a path.
We say the walk visits vertices vi (0 i n) and that {vi , vi+1 } are the edges
of the walk. If n is the number of edges, n is the length of the walk.
A circuit in G is a walk v0 , . . . , vn such that v0 = vn .

5
A cycle in G is a path v0 , . . . , vn such that v0 = vn . If n = 0 or n = 2 we call
it a trivial path.
Ex.

f d

g c
e

a b

geabcdef def geabc are walks.


geabcd gf ebc are paths.
geabef g geabedceg are circuits.
gef g eabcde are cycles.

Connected Components of a graph. Connected graphs.


Def.
Let G = (V, E) be a graph. We say two vertices x, y V are connected by a
walk v0 , . . . , vn if v0 = x and vn = y
Lemma 1
Let G = (V, E) be a graph. Two vertices x, y V are connected by a walk iff
x, y are connected by a path.
Proof
=) It is trivial because every path is a walk.
=) Let us suppose x 6= y since if x = y it is trivial, and let
x = u0 , u1 , . . . , un = y
be a walk joining x with y. If it is already a path, there is nothing to prove,
but if it is not there must exist i, j 0 i < j n such that ui = uj .

ui1 uj+1 un = y
ui = uj
u0 = x

We can then consider a shorter walk joining x and y:


x = u0 , u1 , . . . , ui1, ui , uj+1, . . . , un = y

6
ui1 uj+1 un = y
ui = uj
u0 = x

Repeating this process we may finally obtain a path joining x and y.

Def.
Let G = (V, E) be a graph. We define a relation C as follows:

xCy x and y can be joined by a path in G.

Lemma 2
C is an equivalence relation.
Proof
C is clearly reflexive and symmetric. Let us show it is also transitive.
x, y, z V, xCy, yCz = xCz
There is a path x = v0 , v1 , . . . , vn = y joining x and y and there is another
path y = u0 , u1 , . . . , um = z joining y and z. Hence, there is a walk (there
may be vertices repeated) joining x and z, namely x = v0 , v1 , . . . , vn = y =
u0 , . . . , um = z. By Lemma 1 there is a path joining x and z, that is xCz.

Def.
Let G = (V, E) be a graph and let x V . The equivalence class of x, [x]C ,
determined by C
[x]C = {y V |xCy}
is called the connected component of x. The complete subgraph (vertices
+ edges) given by this equivalence class is also called the connected com-
ponent of x.

Ex.

a b f h

e j i

d c g

This graph has three connected components: [a] = {a, b, c, d} [e] = {e, f, g}
[h] = {h, i, j}.

Def.
If a graph G = (V, E) has just one connected component it is said to be
connected.
Any two vertices of a connected graph are joined by a path.

7
If a graph is connected there is a walk v0 , . . . , vn that visits each vertex of G.
If a graph G = (V, E) is connected, if |V | = n it must have at least n 1
edges.

Ex.

2 3

0
1 4

6 5

A walk that visits all vertices of G: 0, 1, 2, 0, 3, 4, 0, 5, 6

Def.
A cut vertex of a graph G = (V, E) is a vertex v V such that its re-
moval and all edges incident with it produces a subgraph with more connected
components than G.

Ex.

=
a

1 connected component 3 connected components


a is a cut vertex

Def.
A tree is a connected graph with no cycles.

Def.
A rooted tree is a tree T in which one vertex x0 , called the root, is distin-
guished in some way.

f g a c

d b b a
c
d e
b
a e f g e d
With root a g
c f
With root c
8
Hamiltonian Graphs.

Def.
A Hamiltonian cycle or Hamilton cycle is a cycle that visits every vertex
of a graph. We say a graph is a Hamiltonian graph if it contains a Hamilton
cycle.

1 2 a d

b c

d
4 3 a
b c
K4 Q3 (A cube)
1, 2, 3, 4, 1 a, b, c, d, d, c , b , a , a
Hamilton cycles.

To look for a Hamilton cycle corresponds to many practical problems. For


example, a traveling salesman who has to visit a finite number of cities and
wants to do so without visiting any city twice.
This is possible only if the graph is Hamiltonian.
The best algorithms known for finding a Hamilton cycle in a graph or deter-
mining that no such cycle exists have exponential worst-case time complexity
(in the number of vertices of the graph).

Necessary Conditions for a graph to be Hamiltonian.

G must be connected.
G cannot have vertices of degree 1 and every vertex is of degree 2
G cannot have cut vertices

These conditions are not sufficient:

Connected but Connected, no vertices of deg 1 Connected, no vertices of deg 1


not Hamiltonian not Hamiltonian no cut vertices, not Hamiltonian

9
Sufficient Conditions for a graph to be Hamiltonian.
Theorem(Dirac)
n
Let G = (V, E) be a connected graph with n = |V | 3. If v V deg(v)
2
then G is Hamiltonian.
Diracs theorem is a consequence of Ores theorem.
Theorem(Ore)
Let G = (V, E) be a connected graph with n = |V | 3. If deg(u) + deg(v) n
for every pair of non-adjacent vertices u and v of G, then G is Hamiltonian.
Proof
If n = 3 the only graph satisfying the assumption is K3 . It is Hamiltonian.
Let n 4 and suppose G verifies the hypothesis but it is not Hamiltonian. If
we add edges to the graph, the assumption will still hold. Add edges to G until
we reach the graph G = (V, E ) such that it is not Hamiltonian, but addition
of any new edge would give a Hamiltonian graph.
Let e = {u, w} V V be an edge 6 E . G {e} has a Hamiltonian cycle:
u = v0 , v1 , v2 , . . . , vn1 = w, u (using e)
We now consider walk P : u = v0 , v1 , v2 , . . . , vn1 = w length = n 1 and
v V v P
Let
Eu = {{vi , vi+1 }|{u, vi+1} E}
Ew = {{vi , vi+1 }|{vi, w} E}
Using the assumption of the theorem, we get |Eu | + |Ew | n thus, there is an
edge {vi , vi+1 } Eu Ew . i 6= 0 and i 6= n 2, since {u, w} 6 E.

u v1 v2 vi vi+1 vn2 w

We have found a Hamiltonian cycle in G


These conditions are not necessary.
Ex.

This is a Hamiltonian graph but does not verify the hypothesis of diracs and
Ores theorems.

10
Multigraphs.
Sometimes vertices can be connected by more than one edge. This situation
gives rise to the concept of multigraphs. Graphs are a particular case of multi-
graphs.

Def.
A multigraph G = (V, E, I) consists of a set V of vertices, a set E of edges
and an incidence relation I V E V such that:

1. x V, e E (x, e, x) 6 I (loops are not allowed)


2. x, y V, e E if (x, e, y) I = (y, e, x) I (directed edges are not
considered)

When (x, e, y) I we say edge e connects vertices x, y.

Ex.
e1

1 2
e2
e3 e4

V = {1, 2, 3} E = {e1 , e2 , e3 , e4 } I = {(1, e1, 2), (1, e2 , 2), (1, e3, 3), (2, e4, 3)}
deg(1) = deg(2) = 3 deg(3) = 2.

Def.

A walk in a multigraph is a sequence of vertices and edges v0 , e1 , v1 , . . . , vn1 , en , vn


such that 1 i n we have (vi1 , ei , vi ) I
A path in a multigraph is a walk v0 , e1 , v1 , . . . , vn1 , en , vn such that
vi 6= vj if i 6= j for 0 i, j n
A walk in which v0 = vn is called a circuit.
A path in which v0 = vn is called a cycle.
Let G = (V, E, I) be a multigraph. We may define relation C V V

xCy x, y are connected by a path.

C is an equivalence relation, so we may also consider the equivalence


classes which are the connected components of a multigraph.
A multigraph G = (V, E, I) is connected if it has just one equivalence
class determined by C.

We are now going to study walks which use each edge of a graph exactly once.
Euler was the first to study such walks.

11
Def.
Let G = (V, E, I) be a multigraph.
An Eulerian or Euler circuit is a circuit containing every edge of G exactly
once.
An Eulerian or Euler walk is a walk containing every edge of G exactly
once.
We say a multigraph is Eulerian if it contains an Euler circuit and we say it
is semi-Eulerian if it contains an Euler walk.
Every Eulerian graph is semi-Eulerian.
It is much more difficult to determine if a graph is Hamiltonian rather than
Eulerian.

Theorem
Let G = (V, E, I) be a connected multigraph.

1. G is Eulerian Every vertex x V has even degree.


2. G is semi-Eulerian Every vertex x V has even degree or G has
exactly two vertices of odd degree and all the other vertices have even
degree.

Proof
We prove (2) assuming (1) is true.
=)
Let R : u = x0 , e1 , x1 , . . . , xn1 , en , xn = v be an Euler walk in G.
If u = v, R is a circuit, G is Eulerian and by (1) every vertex has even degree.
If u 6= v, if we add an edge e joining u with v we obtain an Eulerian multigraph
G and by (1) all vertices of G have even degree. Hence, all vertices of G, except
u, v have even degree.
=)
If every vertex has even degree, G is Eulerian by (1).
If G has exactly two vertices of odd degree u, v, if we add an edge e connecting
u with v, we obtain a multigraph G such that all vertices are of even degree.
By (1), G has an Euler circuit C. Without loss of generality we may suppose
C is v, e, u, . . . , v. If we delete edge e, we obtain an Euler walk from u to v.
Hence G is semi-Eulerian.

Proof of (1).
=)
Suppose G has an Euler circuit. It begins with a vertex a and continues with
an edge incident to a, say e. This edge contributes 1 to deg(a). Each time the
circuit passes through a vertex it contributes 2 to the vertexs degree since
the circuit enters via an edge incident with this vertex and leaves via another
such edge. Finally the circuit terminates where it started, contributing 1 to
deg(a). Therefore deg(a) must be even and vertices other than a, also must

12
have even degree because the circuit contributes 2 to its degree each time it
passes through the vertex.
=)
The proof is by induction on the number of edges n in G.
Basis step (n = 0).
Since G is connected, if G has no edges G has a single vertex. An Euler circuit
consists of the single vertex and no edges.
Inductive Step.
Suppose that G has n edges, n > 0 and that any connected graph with k
edges, k < n, in which every vertex has even degree, has an Euler circuit.
We will form a circuit that begins at an arbitrary vertex a V . First, we
arbitrarily choose an edge e1 incident with a. We continue by building a walk
a = v0 , e1 , v1 , . . . , vn1 , en , vn that is as long as possible.

v4
5 4
v6 6 v2
v3
3
7 2
1 v1
a

a, 1, v1, 2, v2 , 3, v3 , 4, v4 , 5, v2 , 6, v6, 7, a

The walk terminates, since the graph has a finite number of edges. It begins
at a with an edge e1 and finishes at a with an edge en , (vn = a). This follows
because each time the walk goes through a vertex with even degree, it uses
only one edge to enter this vertex, so that at least one edge remains for the
walk to leave the vertex. This circuit may use all the edges or it may not.
An Euler circuit has been constructed if all the edges have been used. Other-
wise consider subgraph H obtained from G by deleting the edges already used
and vertices that are not incident with any remaining edges.
Since G is connected, H has at least one vertex in common with the circuit
that has been deleted. Let w be such a vertex.
Every vertex in H has even degree (because in G all vertices had even degree
and for each vertex, pairs of edges incident with this vertex have been deleted
to form H.)
H may not be connected. Let H1 , . . . , Hk be the connected components of H.
Each Hi 1 i k has less edges than G. By the inductive hypothesis we
can obtain Euler circuits Ci for each Hi . Since, there is at least a vertex wi
common to C and each Ci , we may combine C, C1, . . . Ck to obtain an Euler
circuit in G.

13
2 1

3 w1

w2 1

4 2

C1 : 1 , 2 , 3 C2 : 1 , 2 , 3, 4

v4

C1 5 4
v6 6 v2
v3
3
7 2
1 v1
a
C2

a, 1, v1 = w2 , C2 (1 , 2 , 3 , 4 ), w2 = v1 , 2, v2, 3, v3 , 4, v4 , 5, v2 , 6, v6 = w1 , C1 (1 , 2 , 3),
w1 = v6 , 7, a

Ex. The Konigsberg bridge Problem.


In the 18th century, seven bridges connected the four sections in which the
city was divided by the Pregel River.

Euler proved that it was not possible to start at some location in the town,
travel across every bridge without crossing any bridge more than once and
returning to the starting point.
There is no Euler walk or circuit in this multigraph. (1 vertex of degree 5 and
3 vertices of degree 3).

14
Ex.
4 3
2

5
8
1 7
9
6

a 10 b

This graph has two vertices a, b of odd degree.

DIGRAPHS

Def.
A digraph (or directed graph) G = (V, A) consists of a finite set V of vertices
and a relation A V V called adjacency relation.
If (x, y) A we say (x, y) is an arc. (Arcs are ordered pairs (v, w) whereas
edges are unordered pairs {v, w}).
An arc (v, v) is said to be a loop.

Ex.
a b c
f

e
d

The definitions of walk, path, circuit and cycle carry over from graphs to
digraphs in an obvious way.

Def.
Let G = (V, A) be a directed graph.

A directed walk in a digraph is a sequence of vertices v1 , v2 , . . . , vk such


that (vi , vi+1 ) A 1 i k 1
A directed walk is a directed path if all its vertices are distinct.
A directed walk is a directed circuit if v1 = vk .
A directed walk is a directed cycle if all its vertices are distinct and
v1 = vk .

15
Representation of Directed Graphs
We may represent directed digraphs by means of adjacency lists and adja-
cency matrices.
Ex.
a b c 1 2
f

e
d 4 3
D1 D2

a
b c 1 1 2
c 2
d c b 3 2 4
e a d e f 4 1 3
f

D1 D2

The adjacency matrix is the nn matrix M (n = |V |) such that each entry



0 if there is no arc from vi to vj
M[i, j] =
1 if there is an arc from vi to vj

a b c d e f

a 0 0 0 0 0 0
b 0 0 1 0 0 0 1 2 3 4

0
1 1 1 0 0
c 0 0 0 0 0

0
2 0 0 0 0
d 1 1 0 0 0

1
3 0 1 0 1
e 0 0 1 1 1
4 1 0 1 0
f 0 0 0 0 0 0

In general the adjacency matrix of a directed graph is not symmetric.


Def.
D2 = (V2 , A2 ) is a directed subgraph of D1 = (V1 , A1 ) iff V2 V1 and
A2 A1 .
If V2 V1 , and A2 = A1 (V2 V2 ) we say D2 is a complete subgraph of
D1 .
.

16
Def.
(V1 , A1 ) (V2 , A2 ) are isomorphic digraphs if there exists a bijection :
V1 V2 such that
x, y V1 , xA1 y (x)A2 (y)

Def. Degree of vertices


Let v V be a vertex. In a digraph we distinguish between:
out-degree + (v) = number of arcs (v, u)
in-degree (v) = number of arcs (u, v)

Theorem
Let G = (V, A) be a directed graph.
X X
+ (v) = |A| = (v)
vV (G) vV (G)

Ex.
a b
e
+ (a) + + (b) + + (c) + + (d) + + (e) = 2 + 2 + 0 + 1 + 1 = 6

(a) + (b) + (c) + (d) + (e) = 0 + 1 + 2 + 1 + 2 = 6


c d

Connected Digraphs
Def.
Let D = (V, A) be a digraph. Let x, y V . We say
y is accesible from x there is a path from x to y.
(In general this is not an equivalence relation.)
We say D = (V, A) is a connected digraph if there exists a vertex x0 such
that each y V is accesible from x0 .
Ex.

Connected Digraph Not Connected Digraph

17

Das könnte Ihnen auch gefallen