06 - Graph-2
06 - Graph-2
22/05/2020
Outline
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
Definition
A (undirected) graph G = (V , E ) is defined by:
1 A non-empty set V of vertices;
2 A set E of edges, which are unordered pairs of vertices.
Example:
V = {a, b, c, d, e, f , g}
E = {{a, b} , {a, f } , {b, c} , {b, e} , {b, f } , {c, d} , {c, e} , {c, f } , {e, f }}
Social networks:
Each vertex represents a person
Two friends are connected by an edge
Computer networks:
Each vertex represents a server
Each edge represents a link
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
The notions of simple directed graphs, multiple arcs, loops and directed
multigraphs are defined similarly to the undirected case.
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
Definition
Two vertices u and v are adjacent if they are endpoints of the same edge e.
In this case, u is a neighbor of v and the edge e is incident with the vertices
u and v .
The set of all neighbors of a vertex v is the neighborhood of v and is denoted
by N(v ). The neighborhood of a set A of vertices
S is the union of the
neighborhoods of the vertices in A: N(A) = N(v ).
v ∈A
Definition
The degree of a vertex v , denoted by deg(v ) or simply d(v ), is the number of
edges incident with it. A loop contributes 2 to the degree of its endpoint.
Note:
A vertex is isolated if it has degree 0; it is pendant if it has degree 1.
In a multigraph, the degree of a vertex may be greater than the number of its
neighbors!
Theorem
Let G = (V , E ) be an undirected graph. Then
X
deg(v ) = 2 |E | .
v ∈V
Proof: Each edge contributes 2 to the sum of degrees of all the vertices.
Corollary
There are an even number of vertices of odd degrees.
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
Definition
If a = (u, v ) is an arc, then u is adjacent to v and v is adjacent from u; u is the
initial node and v is the end node of a; a is an out-going arc of u and an in-going
arc of v .
Definition
The out-degree (resp. in-degree) of a node v , denoted by deg+ (v ) or d + (v ) (resp.
deg− (v ) or d − (v )), is the number of out-going (resp. in-going) arcs of v .
Theorem
Let G = (V , A) be a directed graph. Then
X X
deg+ (v ) = deg− (v ) = |A| .
v ∈V v ∈V
Definition
A complete graph of n vertices, denoted by Kn , is a simple graph having n vertices
and such that every pair of vertices is connected by an edge.
Definition
A path on n vertices, denoted by Pn , is a simple graph having n vertices
{v1 , v2 , . . . , vn } and n − 1 edges {{vi , vi+1 } |1 ≤ i ≤ n − 1}.
Figure: P6
Definition
A cycle on n ≥ 3 vertices, denoted by Cn , is a simple graph having n vertices
{v1 , v2 , . . . , vn } and n edges {{vi , vi+1 } |1 ≤ i ≤ n} (vn+1 ≡ v1 ).
Definition
A wheel graph of n + 1 vertices (n ≥ 3), denoted by Wn , is a simple graph
obtained from Cn by adding a new vertex and connecting it to every vertex of Cn .
Examples:
The path P5 is a bipartite graph.
The cycle C6 is a bipartite graph.
The cycle C3 is not a bipartite graph.
The complete graph K4 is not a bipartite graph.
The hypercubes Q1 , Q2 , Q3 are bipartite graphs.
It is.
Theorem
A simple graph is bipartite iff. its vertices can be colored by two different colors so
that no two adjacent vertices have the same color.
Examples:
Cn is bipartite iff. n is even.
Pn is bipartite for all n.
Qn is bipartite for all n.
Definition
A subgraph of a graph G = (V , E ) is a graph H = (W , F ) where W ⊂ V , F ⊂ E .
Examples:
Every graph is a subgraph of itself.
The path Pn is a subgraph of the cycle Cm if n ≤ m.
The cycle Cn is a subgraph of the wheel Wn .
Every graph on n vertices is a subgraph of Kn .
Definition
Let G = (V , E ) be a simple graph and let W be a subset of vertices. The
subgraph induced by W is the subgraph of G where:
The set of vertices is W ;
The set of edges consists of all edges having both endpoints in W .
Examples:
Cn is the subgraph of Wn induced by the “outer” vertices.
If m ≤ n, Km is the subgraph of Kn induced by a subset of m vertices.
Pn is not an induced subgraph of Cn .
Qn−1 is the subgraph of Qn induced by all vertices whose labels starts with 0.
Vertex removal:
G − v = (V \ {v } , E \ {e | e is incidence with v }).
Result: a subgraph of G.
Edge contraction:
Remove an edge, then merge its endpoints.
Result: not necessarily a subgraph!
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
5 Graph representation
Adjacency list
Adjacency matrix
Incidence matrix
Example:
Note: The notions of adjacency matrix and incidence matrix can be extended for
multigraphs, for directed graphs, etc.
H.-T. Nguyen Graph 22/05/2020 44 / 44