Notes Graph
Notes Graph
Definition 1
An undirected graph G = (V, E) consists of a set V of elements called vertices, and a
multiset E (repetition of elements is allowed) of pairs of vertices called edges.
The order of a graph G(V, E) is |V |; the size of G(V, E) is |E|. A graph of order p and
size q is called a (p, q)-graph.
v1 , e1 , v2 , e2 , . . . , ek−1, vk ,
A distance dist(v, u) between two vertices u and v of a connected graph is the length of
the shortest path connecting them. For a connected graph G.
A graph is called a tree, if it is connected and has no cycles. A leaf is a vertex of degree
1. A rooted tree is a tree with a distinguished vertex, called root. A level of a vertex
1
in a rooted tree is the distance from the vertex to the root. If a vertex v lies on the path
from the root to a vertex u, then v is called an ancestor of u; if additionally, u and v are
adjacent then u is a child of v and v is a parent of u. An ordered tree is a rooted tree
in which the children of every vertex are assigned a fixed ordering. A binary tree is an
ordered tree in which every vertex has at most two children, one of which is called the
left child and the other is called the right child.
Proof. Consider a longest path P in a given tree T (note that there can be more than
one longest path). Let u and v be the endpoints of P . Then each of these two vertices is
a leaf, since otherwise either, T has a cycle, or P is not a longest path.
INDUCTIVE STEP. Let the statement hold for some p ≥ 0 and let T be a tree with
p + 1 vertices. Then by Theorem 1, T has a leaf x. T − x must be a tree, since if x were
on a path connecting some two vertices then x would be of degree ≥ 2. In the tree T − x,
there are p − 1 vertices and p − 2 edges (by induction.) We finish the proof noticing that
removing x, removes exactly one edge.
a b c d
The order (size) of a graph G(V, E) is the number of vertices (edges) or vertex number
(edge number), written |V | (|E|). A graph of order p and size q is called a (p, q)-graph.
For a digraph G parallel arcs (same tail and same head) are not allowed; loops (an arc
whose tail coincides with the head) are not allowed either. If parallel edges and/or loops
are allowed, the object is called directed pseudo-graph.
For a digraph G:
N + (v) = {u : (v, u) ∈ E(G)}; out-neighborhood;
N − (v) = {u : (u, v) ∈ E(G)}; in-neighborhood;
N + (v) ∪ N − (v) = {u : (u, v) ∈ E(G) or (v, u) ∈ E(G)}; neighborhood;
If A ⊆ V (G), then N + (A) = x∈A N + (x) − A.
S
Theorem 3
deg + (x) = |E(G)|.
X X
deg − (x) =
x∈V (G) x∈V (G)
Reversing the edge (u, v) is replacing the edge with (v, u). The converse of G is a
digraph obtained from G by reversing all edges.
3
Contraction of a subgraph H in a graph G is the replacement of V (H) with a new
vertex z and creating new edges (x, z) (resp. (z, y)) iff there is any edge (x, t) (resp.
(s, y)), where t ∈ V (H) (resp. s ∈ V (H)).
W = x1 a1 x2 · · · xk−1 ak−1 xk ,
A trail is a walk in which all edges are distinct. A path is a trail in which all vertices
are distinct. A cycle is a closed walk in which all vertices are distinct, except the last
and the first.
Proposition 3 If G is an acyclic graph with exactly one vertex x of in-degree zero, and
exactly one vertex y of out-degree zero, then for every v ∈ V (G), there is an (x, v)-path
and (v, y)-path.
4
4 6
5
5
3 Graph representation
Adjacency matrix:
Incidence matrix:
Adjacency list:
1 2 3 4 5 6
2 1 1 1 4 6
3 3 2 5
4 6
4 Distances in digraphs
The distance dist(x, y) from x to y is the length of the shortest (x, y)-path.
Define
dist(X, Y ) = max dist(x, y);
x∈X;y∈Y
6
rad+ (G) = min dist(v, V (G));
v
−
rad (G) = min dist(V (G), v);
v
dist(v, V ) + dist(V, x)
rad(G) = min .
v 2
Theorem 4 Let A be the adjacency matrix of a digraph G with n vertices and let Ak be
the k-th power of A. Then for every i, j ∈ [0, n − 1], the entry aki,j of Ak is the number of
walks of length k from vi to vj .
Proof. Induction on k.
7
5 Set-Theory.
∀y ∈ B, ∃x ∈ A, f (x) = y.
Definition 4 Two sets A and B are called of the same size, or of the same cardi-
nality, if there exists a one-to-one, onto function f : A → B.
one-to-one
onto
same cardinality
Proposition 6
Let N be the set of all non-negative integers, and let Ne be the set of all even non-negative
integers. Then N and Ne are of the same cardinality.
f (i) = 2i, i ∈ A.
8
Theorem 5 Let Q be the set of positive rational numbers. Then Q is countable.
1 1 1 1 1 1 2 4 7 11
1 2 3 4 5
2 2 2 2 2 5
1 2 3 4 5 3 8 12
3 3 3 3 3 6
1 2 3 4 5 9 13
4 4 4 4 4
1 2 3 4 5 10 14
5 5 5 5 5
1 2 3 4 5 15
Theorem 6 Let SUBf be the set of all finite subsets of N . Then SUBf is countable.
By construction, the kth entry of s is different from fk (k), thus s is different from every
f (k) (k = 1, 2, . . . .) This proves that f is not a mapping onto; consequently, R is not
countable.
Remark 1 The argument used for the proof of the previous theorem is called the diagonalization
argument.