Discrete Mathematics
(CSC 1204)
9.3 Representing Graphs and
Graph Isomorphism
1
Representing Graphs and Graph Isomorphism
• Graph Representation:
– Adjacency lists
– Adjacency matrices
– Incidence matrices
• Graph isomorphism:
– Two graphs are isomorphic iff they are identical except for
their node names
2
Representing Graphs
• One way to represent a graph without multiple edges is to list
all the edges of the graph.
• Another way to represent a graph with no multiple edges is to
use adjacency lists, which specify the vertices that are
adjacent to each vertex of the graph.
• Adjacency Lists: A table with 1 row per vertex, listing its
adjacent vertices.
• Directed Adjacency Lists: A table with 1 row per node, listing
the terminal nodes of each edge incident from that node.
3
Representing Graphs
• EXAMPLE 1(p.612): Use adjacency lists to describe
the simple graph given in Figure 1.
4
Representing Graphs
• EXAMPLE 2(p.612): Represent the directed graph shown in
Figure 2 by listing all the vertices that are the terminal vertices
of edges starting at each vertex of the graph.
5
Representing Graphs
• Two types of matrices commonly used to represent
graphs –
1) Adjacency matrix
2) Incidence matrix
• Adjacency matrix: A matrix representing a graph
using the adjacency of vertices.
• Incidence matrix: A matrix representing a graph
using the incidence of edges and vertices.
6
Adjacency matrices
• Suppose that G = (V, E) is a simple graph where |V|= n.
Suppose that the vertices of G are listed arbitrarily as v1, v2,
…., vn.
The adjacency matrix A of G, with respect to this listing of the
vertices, is the n x n zero-one matrix with 1 as its (i,j)th entry
when vi and vj are adjacent, and 0 as its (i,j)th entry when
they are not adjacent.
• In other words, if its adjacency matrix is A = [ aij ], then
aij = 1
if {vi, vj} is an edge of G,
0
otherwise
7
Adjacency matrices : Example 3(p.612)
8
Adjacency matrices
• Example 4(p.613) : Draw a graph with the adjacency matrix
0
1
1
0
1
0
0
1
1
0
0
1
0
1
1
0
Solution:
a
d
b
c
9
Adjacency matrices
• Adjacency matrix can also be used to represent
undirected graphs with loops and with multiple
edges.
– A loop at the vertex ai is represented by 1 at the (i,j)th
position of the adjacency matrix.
– When multiple edges are present, the adjacency matrix is
no longer zero-one matrix, because the (i,j)th entry of this
matrix equals the number of edges that are associated to
{ai ,aj }
– All undirected graphs, including multigraphs and
pseudographs, have symmetric adjacency matrices
10
Adjacency Matrices
• Example : What’s the adjacency matrix of the following
graph?
a
b
c
d
11
Adjacency Matrices
a
b
c
Solution:
0
2
1
0
d
2
1
2
1
1
0
0
0
0
0
0
1
12
Practice at Homework
• Example 5 (p. 613): Use an adjacency matrix to
represent the pseudograph shown in Figure 5.
13
Adjacency matrices for directed graph
• Adjacency matrices can also be used to represent
directed multigraphs.
– However, such matrices are not zero-one matrices when
there are multiple edges in the same direction connecting
two vertices
• In the adjacency matrix for a directed graph, aij
equals the number of edges that are associated to
(vi ,vj ).
14
Adjacency matrices for directed graph
Example : What is the adjacency matrix?
b
a
d
c
15
Adjacency Matrices
b
a
Solution:
0
0
0
0
d
c
3
0
1
2
1
2
0
0
1
0
0
0
16
Incidence matrices
• Incidence matrix: A matrix representing a graph using the
incidence of edges and vertices.
• Let G = (V, E) be an undirected graph. Suppose that v1, v2, ….,
vn are the vertices and e1, e2, …., em are the edges of G.
Then the incidence matrix with respect to this ordering of V
and E is the n x m matrix, M = [mij], where
mij =
1
when edge ej is incident with vi ,
0
otherwise
17
Example 6 (p. 614) : Finding the Incident Matrix
18
Example 7 (p. 615) : Finding the Incident Matrix
19
Isomorphism of Graphs
• Definition 1: The simple graphs G1 = (V1, E1) and G2 = (V2, E2)
are isomorphic if there is a one-to-one and onto function f
from V1 to V2 with the property that a and b are adjacent in G1
iff f(a) and f(b) are adjacent in G1 , for all a and b in V1 .
Such a function f is called an isomorphism.
– When two simple graphs are isomorphic, there is a one-toone correspondence between vertices of the two graphs
that preserves the adjacency relationship
– Two graphs are isomorphic iff they are identical except for
their node names
– Isomorphism of simple graphs is an equivalence relation
20
Isomorphism of Graphs
• Intuitively, two graphs are isomorphic if can bend,
stretch and reposition vertices of the first graph,
until the second graph is formed. Etymologically,
isomorphic means “same shape”.
e.g.: Can twist or relabel:
to obtain:
21
Example 8 (p.615)
• Show that the graphs G=(V,E) and H=(W,F) are isomorphic.
u1
u2
v1
v2
u3
u4
v3
v4
G
H
22
Solution of Example 8 (p.615)
• The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3, and
f(u4)= v2 is a one-to-one correspondence between V
and W. To see that this correspondence preserves
adjacency, note that adjacent vertices in G are u1 and
u2, u1 and u3, u2 and u4, and each of the pairs f(u1)=
v1 and f(u2) = v4, f(u1)= v1 and f(u3)= v3, f(u2)= v4 and
f(u4)= v2, and f(u3)= v3 and f(u4)= v2 are adjacent in H.
• So, the graphs G and H are isomorphic.
23
Isomorphism of Graphs
• It is often difficult to determine whether two simple graphs
are isomorphic.
• Sometimes it is not hard to show that two graphs are not
isomorphic.
• A property preserved by isomorphism of graph is called a
graph invariant.
• Isomorphic simple graphs must have –
– The same # of vertices
– The same # of edges
– The degrees of the vertices must be the same
24
Example 9(p.616)
• Show that the following two graphs G and H are not
isomorphic.
b
b
a
c
a
c
e
d
G
e
d
H
25
Solution of Example 9(p.616)
• Solution : Both G and H have five vertices and six
edges. However, H has a vertex of degree one,
namely e, whereas G has no vertices of degree one.
It follows that G and H are not isomorphic.
26
Isomorphism of Graphs
• Note: The number of vertices, the number of edges,
and the number of vertices of each degree are all
invariants under isomorphism. If any of these
quantities differ in two simple graphs, these graphs
cannot be isomorphic.
• However, when these invariants are the same, it does
not necessarily mean that the two graphs are
isomorphic. There are no useful sets of invariants
currently known that can be used to determine
whether simple graphs are isomorphic.
27
Properties of Isomorphism
• Since graphs are completely defined by their vertex
sets and the number of edges between each pair,
isomorphic graphs must have the same intrinsic
properties, i.e. isomorphic graphs have the same…
…number of vertices and edges
…degrees at corresponding vertices
…types of possible sub-graphs
…any other property defined in terms of the basic
graph theoretic building blocks!
28
Graph Isomorphism : Negative Examples
Q: Why are the following graphs non-isomorphic?
u2
u1
u5
v2
u3
u4
v1
v3
v4
29
Graph Isomorphism : Negative Examples
A: 1st graph has more vertices than 2nd.
Q: Why are the following graphs non-isomorphic?
u2
u1
u5
v2
u3
u4
v1
v5
v3
v4
30
Graph Isomorphism : Negative Examples
A: 1st graph has more edges than 2nd.
Q: Why are the following graphs non-isomorphic?
u2
u1
u5
v2
u3
u4
v1
v5
v3
v4
31
Graph Isomorphism : Negative Examples
A: 2nd graph has vertex of degree 1, 1st graph doesn't.
Q: Why are the following graphs non-isomorphic?
u1
u2
u3
u7
u8
u4
u5
u9
u6
v1
v2
v7
v3
v4
v5
v8
v9
v6
32
Graph Isomorphism : Negative Examples
• A: 1st graph has 2 degree 1 vertices, 4 degree
2 vertex and 2 degree 3 vertices. 2nd graph
has 3 degree 1 vertices, 3 degree 2 vertex and
3 degree 3 vertices.
33
Homework
• Example 10 (p.616)
• Example 11 (p.617)
• Relevant Exercises (p.618 –21)
34
© Copyright 2026 Paperzz