Sei sulla pagina 1di 53

An introduction to graph theory

Arash Rafiey

13 October, 2015

Arash Rafiey An introduction to graph theory


Definition of Graph

Let V be a finite nonempty set and let E ⊆ V × V .


(V , E ) is called a digraph where V is a set of vertices and E is
called a set of (directed) edges or arcs.

Arash Rafiey An introduction to graph theory


Definition of Graph

Let V be a finite nonempty set and let E ⊆ V × V .


(V , E ) is called a digraph where V is a set of vertices and E is
called a set of (directed) edges or arcs.
When the order does not matter (relation is symmetric) we have a
graph G = (V , E ) and E (G ) ⊆ {{u, v }|u, v ∈ V (G )}

a a

c b c
b

d e
d e
V={a,b,c,d,e} V={a,b,c,d,e}

E={{a,b},{a,c},{b,c},{b,d},{d,c},{c,e}} E={(a,b),(b,d),(d,b),(c,b),(c,e)}

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .
An x − y walk is an alternating sequence of vertices and edges,
starting at x and ending at y .

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .
An x − y walk is an alternating sequence of vertices and edges,
starting at x and ending at y .

If x = y then the walk is called closed.

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .
An x − y walk is an alternating sequence of vertices and edges,
starting at x and ending at y .

If x = y then the walk is called closed.


A trail is a walk in which all the edges are distinct.

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .
An x − y walk is an alternating sequence of vertices and edges,
starting at x and ending at y .

If x = y then the walk is called closed.


A trail is a walk in which all the edges are distinct.
A path is a simple walk (no vertex repeated).

Arash Rafiey An introduction to graph theory


For simplicity instead of edge {u, v } we write edge uv .
Two vertices u and v are called adjacent if uv is an edge of G .
We say v is a neighbor of u if uv is an edge of G .
Let x, y be two vertices of graph G .
An x − y walk is an alternating sequence of vertices and edges,
starting at x and ending at y .

If x = y then the walk is called closed.


A trail is a walk in which all the edges are distinct.
A path is a simple walk (no vertex repeated).
A cycle is a simple closed walk (no vertex repeated except the
beginning ).

Arash Rafiey An introduction to graph theory


Theorem
Let G = (V , E ) be undirected graph with a, b ∈ V , a 6= b. If there
exists a trail from a to b, then there exists a path from a to b.

Arash Rafiey An introduction to graph theory


Theorem
Let G = (V , E ) be undirected graph with a, b ∈ V , a 6= b. If there
exists a trail from a to b, then there exists a path from a to b.

Proof.
Consider the shortens trail a, x1 , x2 , . . . , xn , b in G
(ax1 , x1 x2 , x2 x3 , . . . , xn−1 xn , xn b are edges). If this trail is not a
path then there exist k, m where xk = xm (x0 = a, xm+1 = b,
k < m ). But then we can contract and get a shorter trail
a, x1 , . . . , xk , xm+1 , . . . , xn , b from a to b.

Arash Rafiey An introduction to graph theory


Definition
A graph G is called connected if there is a path between any two
distinct vertices of G .

a a

b c b c

e d e
d

G (connected) H (not connected)

Definition
If G is not connected then it can be partitioned into pieces where
each piece is a connected graph and is called a connected
component .
The number of connected components of G is denoted by κ(G ).

Arash Rafiey An introduction to graph theory


Example :
Let G = (V , E ) be an undirected graph whose vertices are binary
n-sequences and the two vertices x, y are adjacent if they differ in
exactly two positions.
Find κ(G ).

Arash Rafiey An introduction to graph theory


Definition
A graph G is simple if there are no parallel edges and there is no
self-loop.

Arash Rafiey An introduction to graph theory


Definition
A graph G is simple if there are no parallel edges and there is no
self-loop.

Definition
If v is a vertex of graph G , then the degree of v , denoted deg (v )
(dG (v ), or dv ) is the number of edges incident to v . Is the number
of neighbors of v . The self-loop is counted twice.
If G is a simple graph and each vertex has degree k then G is
called a k-regular graph.

Arash Rafiey An introduction to graph theory


Theorem (Handshaking)
For any graph G = (V , E ) we have
X
deg (v ) = 2|E (G )|.
v ∈V

Arash Rafiey An introduction to graph theory


Theorem (Handshaking)
For any graph G = (V , E ) we have
X
deg (v ) = 2|E (G )|.
v ∈V

Proof.
If an edge e has two end points u and v then it will contribute one
to each of deg (u), deg (v ). If e is a self loop incident to vertex u
then it will contribute two to deg (u). In any case each edge
contributes two in the sum and identity follows.

Arash Rafiey An introduction to graph theory


Theorem (Handshaking)
For any graph G = (V , E ) we have
X
deg (v ) = 2|E (G )|.
v ∈V

Proof.
If an edge e has two end points u and v then it will contribute one
to each of deg (u), deg (v ). If e is a self loop incident to vertex u
then it will contribute two to deg (u). In any case each edge
contributes two in the sum and identity follows.

Corollary
In any graph G the number of vertices of odd degree must be even.

Arash Rafiey An introduction to graph theory


Some families of Graphs

1) A graph G is called complete if every vertex is adjacent to


every other vertex.

Arash Rafiey An introduction to graph theory


Some families of Graphs

1) A graph G is called complete if every vertex is adjacent to


every other vertex.
2) For every n ≥ 2, the n-path-graph, denoted by Pn is just a path
on n vertices.
V (Pn ) = {v1 , v2 , . . . , vn } and E (Pn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn }.

Arash Rafiey An introduction to graph theory


Some families of Graphs

1) A graph G is called complete if every vertex is adjacent to


every other vertex.
2) For every n ≥ 2, the n-path-graph, denoted by Pn is just a path
on n vertices.
V (Pn ) = {v1 , v2 , . . . , vn } and E (Pn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn }.
3) For every n ≥ 2, the n-cycle-graph, denoted by Cn is just a cycle
on n vertices.
V (Cn ) = {v1 , v2 , . . . , vn }, E (Cn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn , vn v1 }.

Arash Rafiey An introduction to graph theory


Some families of Graphs

1) A graph G is called complete if every vertex is adjacent to


every other vertex.
2) For every n ≥ 2, the n-path-graph, denoted by Pn is just a path
on n vertices.
V (Pn ) = {v1 , v2 , . . . , vn } and E (Pn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn }.
3) For every n ≥ 2, the n-cycle-graph, denoted by Cn is just a cycle
on n vertices.
V (Cn ) = {v1 , v2 , . . . , vn }, E (Cn ) = {v1 v2 , v2 v3 , . . . , vn−1 vn , vn v1 }.
4) For every n ≥ 2, the n-hypercube, denoted by Qn has vertex set
V (Qn ) = {length n bit string } and two vertices are adjacent if
their bit strings differ in exactly one position.

Arash Rafiey An introduction to graph theory


Bipartite Graphs

Definition
A graph G = (V , E ) is bipartite if V can be partitioned into U, W
such that each edge of G has one end point in U and one end
point in W .

Arash Rafiey An introduction to graph theory


Bipartite Graphs

Definition
A graph G = (V , E ) is bipartite if V can be partitioned into U, W
such that each edge of G has one end point in U and one end
point in W .

Example
For which n, Cn is a bipartite ?

Arash Rafiey An introduction to graph theory


Bipartite Graphs

Definition
A graph G = (V , E ) is bipartite if V can be partitioned into U, W
such that each edge of G has one end point in U and one end
point in W .

Example
For which n, Cn is a bipartite ?
For which value of n, Kn is bipartite ?

Arash Rafiey An introduction to graph theory


Bipartite Graphs

Definition
A graph G = (V , E ) is bipartite if V can be partitioned into U, W
such that each edge of G has one end point in U and one end
point in W .

Example
For which n, Cn is a bipartite ?
For which value of n, Kn is bipartite ?
For which value of n, Pn is bipartite ?

Arash Rafiey An introduction to graph theory


Bipartite Graphs

Definition
A graph G = (V , E ) is bipartite if V can be partitioned into U, W
such that each edge of G has one end point in U and one end
point in W .

Example
For which n, Cn is a bipartite ?
For which value of n, Kn is bipartite ?
For which value of n, Pn is bipartite ?
For which value of n, Qn is bipartite ?

Arash Rafiey An introduction to graph theory


Definition
For positive integers n, m, the complete bipartite graph Kn,m has
the following vertex and edge sets :
V (Kn,m ) = {u1 , u2 , . . . , un } ∪ {v1 , v2 , . . . , vm }
E (Kn,m ) = {ui vj |1 ≤ i ≤ n, 1 ≤ j ≤ m}

K2,3 K3,3

Arash Rafiey An introduction to graph theory


Degree Sequence

Give any graph, we can obtain the degree sequence (d1 , d2 , . . . , dn )


of its vertices v1 , v2 , . . . , vn .

Arash Rafiey An introduction to graph theory


Degree Sequence

Give any graph, we can obtain the degree sequence (d1 , d2 , . . . , dn )


of its vertices v1 , v2 , . . . , vn .
We are given a sequence (d1 , d2 , . . . , dn ). Can we decide whether
there exists a graph G whose degree sequence is (d1 , d2 , . . . , dn ) ?
If this is the case then (d1 , d2 , . . . , dn ) is called a graphic sequence.

Arash Rafiey An introduction to graph theory


Degree Sequence

Give any graph, we can obtain the degree sequence (d1 , d2 , . . . , dn )


of its vertices v1 , v2 , . . . , vn .
We are given a sequence (d1 , d2 , . . . , dn ). Can we decide whether
there exists a graph G whose degree sequence is (d1 , d2 , . . . , dn ) ?
If this is the case then (d1 , d2 , . . . , dn ) is called a graphic sequence.
(2, 2, 2) is graphic but (2, 3, 4, 3, 2, 3) is not graphic.

Arash Rafiey An introduction to graph theory


Theorem
Suppose π = (d1 , d2 , . . . , dn ) is a sequence with
n > d1 ≥ d2 ≥ · · · ≥ dn .
1 If π is graphic then there is a graph G with
V (G ) = {v1 , v2 , . . . , vn } and deg (vi ) = di and the neighbors
of v1 are v2 , v3 , . . . , vd1 +1 .
2 π is graphic if and only if
(d2 − 1, d3 − 1, . . . , dd1 +1 − 1, dd1 +2 , . . . , dn ) is graphic.

Proof.
Proof of (1). Since π is graphic, there is a graph G with vertices
v1 , v2 , . . . , vn and degree sequence π.
We may assume that G = (V , E ) is such a graph that N(v1 ) ∩ S is
maximum where S = {v2 , v3 , . . . , vd1 +1 } (N(v1 ) is the
neighborhood of v1 ). If v1 is adjacent to all the elements in S then
we are done. Otherwise there exists some vk such that v1 vk 6∈ E
and hence there exits ` > d1 + 1 where v1 v` ∈ E .

Arash Rafiey An introduction to graph theory


Proof.
Since k < `, vk has as many neighbors as v` and hence vk has a
neighbor vj that is not neighbor of v` . Now create new graph G 0
by removing edge v1 v` and adding edge v1 vk and removing edge
vk vj and adding edge vj v` . G 0 has the same degree sequence as G
but N(v1 ) ∩ S increases in G 0 , a contradiction.

Arash Rafiey An introduction to graph theory


Proof.
Since k < `, vk has as many neighbors as v` and hence vk has a
neighbor vj that is not neighbor of v` . Now create new graph G 0
by removing edge v1 v` and adding edge v1 vk and removing edge
vk vj and adding edge vj v` . G 0 has the same degree sequence as G
but N(v1 ) ∩ S increases in G 0 , a contradiction.
Proof of (2). If π is graphic then by (1) there is G with vertices
v1 , v2 , . . . , vn and degree sequence π where v1 is adjacent to
v2 , v3 , . . . , vd1 +1 . If we remove v from G then we have a sequence
(d2 − 1, d3 − 1, . . . , dd1 +1 − 1, dd1 +2 , . . . , dn ). Conversely, if we start
with graphic sequence (d2 − 1, d3 − 1, . . . , dd1 +1 − 1, dd1 +2 , . . . , dn )
associated with graph G 0 then we add a new vertex v and connect
it to the vertices of G 0 with degrees d2 − 1, d3 − 1, . . . , dd1 +1 − 1.
This way we obtain G with degree sequence π.

Arash Rafiey An introduction to graph theory


Algorithm to detect graphic sequence

Graphic (n > d1 ≥ d2 ≥ d3 ≥ · · · ≥ dn )
1. while d1 > 0
2. Set (d10 , d20 , . . . , dn−1
0 ) be a non-decreasing permutation of
(d2 − 1, d3 − 1, . . . , dd1 +1 − 1, dd1 +2 , . . . , dn )
3. Set n = n − 1 and (d1 , d2 , . . . , dn ) = (d10 , d20 , . . . , dn0 )
4. if di < 0 then output NO exit
5. else if d1 = 0 then output YES exit

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)
(2) : (1,1,1,1)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)
(2) : (1,1,1,1)
(3) : (0,1,1)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)
(2) : (1,1,1,1)
(3) : (0,1,1)
Sort (1,1,0)

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)
(2) : (1,1,1,1)
(3) : (0,1,1)
Sort (1,1,0)
(4) : (0,0) True

Arash Rafiey An introduction to graph theory


Example
Initial Sequence : (4,4,3,3,2,2)
(1) : (3,2,2,1,2)
Sort : (3,2,2,2,1)
(2) : (1,1,1,1)
(3) : (0,1,1)
Sort (1,1,0)
(4) : (0,0) True
Is the sequence (5, 5, 3, 5, 3, 3, 3, 3) is graphic ?

Arash Rafiey An introduction to graph theory


Subgraphs

Definition
Let G = (V , E ) be a graph. Graph H 0 = (V 0 , E 0 ) is a subgraph of
G if V 0 ⊆ V and E 0 ⊆ E .

Arash Rafiey An introduction to graph theory


Subgraphs

Definition
Let G = (V , E ) be a graph. Graph H 0 = (V 0 , E 0 ) is a subgraph of
G if V 0 ⊆ V and E 0 ⊆ E .

C5 is a subgraph of K6 , and K1 , K2 , . . . , K5 are all subgraph of K6 .

Arash Rafiey An introduction to graph theory


Graph Isomorphism

Definition
Let G = (V , E ), G 0 = (V 0 , E 0 ) two graphs. Suppose f : V → V 0 is
a one-to-one function.
1 f preserve adjacency if for every uv ∈ E , f (u)f (v ) ∈ E 0 .

Arash Rafiey An introduction to graph theory


Graph Isomorphism

Definition
Let G = (V , E ), G 0 = (V 0 , E 0 ) two graphs. Suppose f : V → V 0 is
a one-to-one function.
1 f preserve adjacency if for every uv ∈ E , f (u)f (v ) ∈ E 0 .
2 f preserve non-adjacency if for every non adjacent vertices
u, v then f (u), f (v ) are non-adjacent.

Arash Rafiey An introduction to graph theory


Graph Isomorphism

Definition
Let G = (V , E ), G 0 = (V 0 , E 0 ) two graphs. Suppose f : V → V 0 is
a one-to-one function.
1 f preserve adjacency if for every uv ∈ E , f (u)f (v ) ∈ E 0 .
2 f preserve non-adjacency if for every non adjacent vertices
u, v then f (u), f (v ) are non-adjacent.
3 f is a graph isomorphism from G to G 0 if it is bijective and
preserve both adjacency and non-adjacency. In this case we
write G ∼= G 0.

Arash Rafiey An introduction to graph theory


Graph Isomorphism

Definition
Let G = (V , E ), G 0 = (V 0 , E 0 ) two graphs. Suppose f : V → V 0 is
a one-to-one function.
1 f preserve adjacency if for every uv ∈ E , f (u)f (v ) ∈ E 0 .
2 f preserve non-adjacency if for every non adjacent vertices
u, v then f (u), f (v ) are non-adjacent.
3 f is a graph isomorphism from G to G 0 if it is bijective and
preserve both adjacency and non-adjacency. In this case we
write G ∼= G 0.

a b c d
G G’ f(a)=c and f(b)=d
f is isomorphism

Arash Rafiey An introduction to graph theory


a b u v
e f y z

h g t s
d c x w
G H

Arash Rafiey An introduction to graph theory


a b u v
e f y z

h g t s
d c x w
G H

e f u v
a b
w x

h g
y z

d c s t

Arash Rafiey An introduction to graph theory

Potrebbero piacerti anche