Matrix Representation of Graphs Graph Isomorphisms

CS 30 : Discrete Mathematics for Computer Science First Semester, AY 2012-2013

https://sites.google.com/a/dcs.upd.edu.ph/nhsh_classes/cs30

sablay-logo

Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University of the Philippines, Diliman nshernandez@dcs.upd.edu.ph updilseal

Day 18

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Theory

1

Matrix Representation of Graphs Adjacency Matrix Incidence Matrix Path Matrix

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Theory

1

Matrix Representation of Graphs Adjacency Matrix Incidence Matrix Path Matrix

2

Graph Isomorphisms

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Adjacency Matrix Incidence Matrix Path Matrix

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix An adjacency matrix of a graph with n vertices is an denoted by A = [aij ], dened as follows:

A=

where,

aij =

a a a

11 21 31

· · ·

an

1

a a a

12 22 32

· · ·

an

2

a a a

13 23 33

· · ·

an

3

··· ··· ··· ··· ··· ··· ···

an an an 1 2 3

· · ·

ann

n × n matrix,

1, if there is an edge from vi to vj 0, otherwise

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Adjacency Matrix Incidence Matrix Path Matrix

1

4

w n loops at vi when ai = n. The graph appears in Fig. 8-52(b). Matrix Representation of Graphs Graph Isomorphisms

Simple Graph

sablay-logo

updilseal

Fig. 8-52 Discrete Mathematics for Computer Science

CS 30

dcs-logo

acl-logo

Adjacency Matrix Incidence Matrix Path Matrix

1

4

w n loops at vi when ai = n. The graph appears in Fig. 8-52(b). Matrix Representation of Graphs Graph Isomorphisms

Simple Graph

sablay-logo

If the main diagonal entries of the adjacency matrix are all zeroes, then the graph is said to be a simple graph.

Fig. 8-52 Discrete Mathematics for Computer Science

CS 30

updilseal

dcs-logo

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Pseudograph Graph In case of a multigraph(pseudograph), the adjacency matrix is given by :

aij =

n, n is the number of edges from vi to vj 0, otherwise

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

ay, v1 , v2 . . . , v5 . Draw an edge from vi to vj when aij = 1. The Pseudograph Graph

In case of a multigraph(pseudograph), the adjacency matrix is given by :

say, v1 , . . . , v4 . Draw n edges from vi to vj when aij = n. Also, n , n is the number of edges from vi to vj aij = 0, otherwise s in Fig. 8-52(b).

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Weighted Graph

Adjacency Matrix Incidence Matrix Path Matrix

Fig. 8-52

8.25. Find the weight matrix W = [wij ] of the weighted graph G in Fig. 8-53(a) where the vertices in the array DATA as follows: DATA: A, B, C, X, Y .

sablay-logo

Fig. 8-53

The vertices are numbered according to the way they are stored in the array DATA; so v1 = A, v2 v5 = Y . Then set Wij = w, where w is the weight of the edge from vi to vj . This yields the matrixupdilseal W in F

LINKED REPRESENTATION OF GRAPHS dcs-logo

8.26. A graph G with vertices A, B, . . . , F is stored in memory using a linked representation with a and an edge file as in Fig. 8-54. Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Weighted Graph

Adjacency Matrix Incidence Matrix Path Matrix

Fig. 8-52

8.25. Find the weight matrix W = [wij ] of the weighted graph G in Fig. 8-53(a) where the vertices in the array DATA as follows: DATA: A, B, C, X, Y .

sablay-logo

In case of a weighted simple graph, the adjacency matrix is given by :

aij =

Fig. 8-53

w , w is the weight of the edge from vi to vj

0, otherwise The vertices are numbered according to the way they are stored in the array DATA; so v1 = A, v2 v5 = Y . Then set Wij = w, where w is the weight of the edge from vi to vj . This yields the matrixupdilseal W in F LINKED REPRESENTATION OF GRAPHS dcs-logo

8.26. A graph G with vertices A, B, . . . , F is stored in memory using a linked representation with a and an edge file as in Fig. 8-54. Discrete Mathematics for Computer Science

CS 30

acl-logo

y defines a directed graph with m vertices. Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Directed Graph

6 Let G be the directed graph in Fig. 9-4(a) with vertices v1 , v2 , v3 , v4 in Fig. 9-4(b). Note that the number of 1â€™s in A is equal to the numbe

sablay-logo

updilseal

Fig. 9-4 2

3

Discrete Mathematics for Computer Science

CS 30

dcs-logo

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Directed Graph

DIRECTED GRAPHS

sablay-logo

updilseal

Fig. 9-7 dcs-logo

pond to the lengths in the matrix Qk .) The entries in the matrix Q0 a Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Incidence Matrix of an Undirected Graph Suppose that G is an undirected graph with m vertices and n edges, then the incidence matrix of G is an m Ă— n matrix B = [bij ] where

bij =

1, if edge ej is incident on vertex vi 0, otherwise

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Incidence Matrix of an Undirected Graph

%/0*(.*123/-'('*4%(0'&%(2/3 Suppose that G is an undirected graph with m vertices and n edges, then the incidence matrix of G is an m Ă— n matrix B = [bij ] where

!"# 5*

!"68 #78

: ; <'-('= " >').#?3 (. '$?'3 #9 1, if edge

e is incident on vertex vi

bij = 0, otherwisej @(0'-A23'

sablay-logo

e7 v4

updilseal

%(-2=*.;*(0'*?-%,0*C*23*.;*.-$'-*FG*ÂĽ*HI9*J0'*2#/2$'#/'*& $ME*$NE*$G*%#$*%6E*%LE*%ME*%NE*%GE*%OE*%H*23*?2<'#*>').AP dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Incidence Matrix of a Directed Graph Suppose that G is a simple directed graph with m vertices and n edges, then the incidence matrix of G is an m × n matrix B = [bij ] where −1 bij = 1, 0,

if edge ej leaves vertex vi if edge ej enters vertex vi otherwise

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Incidence Matrix of a Directed Graph

s of A will be nonnegative integers. Conversely, every m × m matrix Suppose that G is a simple directed graph with m vertices and n edges, y defines directed then athe incidencegraph matrix with of G ismanvertices. m × n matrix B = [bij ] where

−1 if edge ej leaves vertex vi 1, if edge ej enters vertex vi b = ij Let G be the directed graph in Fig. 9-4(a) with vertices v1 , v2 , v3 , v4 0, otherwise

6 in Fig. 9-4(b). Note that the number of 1’s in A is equal to the numbe

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Path Matrix Suppose that G is a graph with P = [pij ] dened by

pij =

n vertices. Then the n Ă— n matrix

1, if there is a path from vi to vj 0, otherwise

sablay-logo

is known as the path matrix or reachability matrix of the graph G.

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

&&7 %7 Path Matrix

7 6 6 6 6 7 7 7 6 7 7 6

)) (

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

&'+,-

&,)'*?-%,0*A2(0*&K<'-(2/'39*J0'#*(0'*F&*¥*&I*&%(-2=*R*5*S'"#*TF&*¥*&I*$';2#'$ Suppose that G is a graph with n vertices. Then the n × n matrix P = [pij ] dened by 23 % ,%(0 ;-.& $" (. $# 68 2; (0'-' ,"# 5* 1, if there is a path from vi to vj p = ij 78 @(0'-A23' 0, otherwise

sablay-logo

0*&%(-2=*.-*-'%/0%>2)2(U*&%(-2=*.;*(0'*?-%,0*C9 is known as the path matrix or reachability matrix of the graph G. 0*C*%3

updilseal

v5

(0*&%(-2=*.;*(0'*%>.<'*?-%,0*-')%(2<'*(.*(0'*.-$'-2#?*$6E*$L()$M*(*$N*E*$G*23

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Adjacency Matrix Incidence Matrix Path Matrix

Path Matrix

s of A will be nonnegative integers. Conversely, every m × m matrix Suppose that G is graph a graphwith with nmvertices. Then the n × n matrix y defines a directed vertices. P = [pij ] dened by

1, if there is a path from vi to vj pij = graph 6 Let G be the directed in Fig. 9-4(a) with vertices v1 , v2 , v3 , v4 0, otherwise in Fig. 9-4(b). Note that the number of 1’s in A is equal to the numbe is known as the path matrix or reachability matrix of the graph G.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

graph by the following table: 2 presented 1 how 1 0 the Show answer, say, to (ii) may be more readily available if the data is stored in memory using the Matrix Representation of Graphs 0linked 0 1representation 1 : Y, Z, W of ;theYgraph 9-26(b). G = [X : X,as Y,inWFig. ; Z : Z, W ; W : Z] Graph Isomorphisms

A is a 4 × 4One matrix, G has four vertices, v1 , va2 breadth-first , v3 , v4 . For each entry aij insearch A, draw aij arcs (directed answer to use algorithm to decideedges) whether city Y is reachable enumber edges {A,of E} vertices andway {A,to E}; and (4)(ii) hasisboth multiple edges or depth-first and edges in G.

Exercise

vertex vfrom vj Such to obtain the graph in Fig.the 9-27(a). i to vertex city X. algorithms require adjacency lists, which can easily be obtained from the linked representation graph G. but not from the above representation which uses only three fields. of of a graph,

Fig. 8-67 any sources or sinks? ells us that there are four vertices, X, Y, Z, W. The outdegrees of the vertices are 3, 3, 2, 1, respectively. MISCELLANEOUS PROBLEMS 1 = 9 edges. are 3 + 3 + 2 + 0 2 0 1 adjacency lists, draw the graph in Fig. 9-24(b). 0 1 1 0 so no 9.15. Let A = be sinks. the adjacency ofhas a multigraph G. Draw of G. is a has zero outdegree, nomatrix vertexin zero indegree, that a is,picture each vertex (a) 2List1thethere vertices in the order in Also, which they appear memory. 1 0are hence there are no sources. 0 0 1 1 (b) Find adjacency structure thatstored is, listusing adj(v) ofaeach vertexrepresentation v of G. raph GSince withAsix A,GB, .four . ., of FG, , is in,adjacency memory linked is a vertices, 4 × the 4 matrix, has vertices, v1 ,find v2 ,the v 3 v4 . For each entry aij in A, draw aij arcs (directed edges) file and anvertex edgevfile as in v Fig. 9-25(a). from to vertex to obtain the graph in Fig. 9-27(a).

(a)

i

j

(b)

(c)

8.71. Exhibit the adjacency structure (AS) for each graph G in Fig. 8-59.

sablay-logo

8.72. Figure 8-68(a) shows aFig. graph G representing six cities A, B, . . ., F connected by seven highways numbered 9-27 22, 33, . . ., 88. Show how G may be maintained in memory using a linked representation with sorted arrays for the cities and for the numbered highways. (Note that VERTEX is a sorted array and so the field NEXT-V is not are four possible topological sorts of S. Specifically, each sort T must begin with either a or b, must end with needed.) , and c and d must be the third and fourth elements, respectively. The four sorts follow: d) G − Y; T2 = [b, a, c, d, e, f ] e) all cut points; T1 = [a, b, c, d, e, f ], T4 = [b, a, c, d, f, e] T3 = [a, b, c, d, f, e], f ) all bridges.

be the cycle-free graph in Fig. 9-27(b). Find all possible topological sorts of S.

(d)

(e)

Proposition 9.4: Let A be the adjacency matrix of a graph G. Then aK [i, j ], the ij-entry in the matrix

and B, Y, C). ves(A, theX, number of paths of length K from vi to vj .

roof is by induction on K. A path of length 1 from vi to vj is precisely an edge (vi , vj ). By definition of the Fig. 9-27 ency matrix A, a1 [i, j ] = aij gives the number of edges from vi to vj . Hence the proposition is true for K = 1.

Fig. 9-25 " " and the of all edges belong to=VA" ,K−1 A, 9.16. Let SE1. be the cycle-free graph Fig.AK 9-27(b). Find all possible topological sorts of S. Suppose Kset> (Assume Gwhose has m endpoints nodes.) in Since ertices in the order they appear m in memory. There are four possible topological ' sorts of S. Specifically, each sort T must begin with either a or b, must end with successor list succ(v) of each vertex v. a [i, j ] = a [i, s] a [s, j] e or f , and c and d must be the third and fourth elements, respectively. The four sorts follow: K K−1 Y graph to obtainoftheG. graph G − Y in Fig. 8-38(c). (Note Y is a1 s=1

T1 = [a, b, c, d, e, f ], T2 = [b, a, c, d, e, f ] duction, aK−1 [i, s] gives the number of paths of length K − 1 from vi to vs and a1 [s, j ] gives the number of T4 = [b, a, c, d, f, e] T3 = [a, b, c, d, f, e], of length 1 from vs to vj . Thus aK−1 [i, s]a 1 [s, j ] gives the number of paths of length K from vi to vj where he next-to-last vertex. Thus all paths from vi to matrix vj can be up[i, thej ], product 9.17. Prove Proposition 9.4: Letof Alength be theKadjacency ofobtained a graphby G.summing Then aK the ij-entry in the matrix ere three bridges: {A,number Z}, {A, X}, and Y }.length i, s]are a1 [s, j ], for all s.the Accordingly, aof j ]{C, is the number of K from vi to vj . Thus the proposition K [i, gives paths of Kpaths fromofvlength AK i to vj . ved. The proof is byDiscrete induction on K . A path of length 1 from vi to vj30is precisely an edge (vi , vj ). By definition of the Mathematics for Computer Science CS

updilseal

dcs-logo

(f)

acl-logo

Drawings for two graphs, (a) and (b), are shown in Figure 8.21. Are they pictures Matrix Representation of Graphs Graph Isomorphisms of the same graph? The transformation of the drawing of (a) into the drawing of (b) shown in Figure 8.22 suggests that the answer is yes.

Compare there graphs ... (a)

(b) 1

6

g

a e

5

f

n 2

b

10

c d

4

h m

l 3

7

k

i

j 9

sablay-logo

8

Figure 8.21 Two Graphs to Compare

(a)

1

c 2

b

1 f

c d

3

4

d

3

b

a 2

!

1

e

d

i

f 4

h

n

b

3

6

g

c

e

!

(b)

5

g

a f

(a)

5

!

2

m

10

7

k

l

i

j 9

updilseal

8

dcs-logo

Figure 8.22 Transforming One Graph into Another Discrete Mathematics for Computer Science

CS 30

acl-logo

offor (b)two shown in Figure 8.22 that the answer is yes. Drawings (a) in and (b), suggests are shown in Figure 8.21.answer Are they pictures of graphs, (b) shown Figure 8.22 suggests that the is yes. Matrix Representation of Graphs Graph Isomorphisms of the same graph? The transformation of the drawing of (a) into the drawing of (b) shown in Figure 8.22 suggests that the answer is yes. Compare there graphs (a)... (a) (b) (b) 1

(a) 1 5

g e

5

g

d4

4

d

4

a

e b f

2c

b c

a

g

e a5 f

f

6

1

2 b

(b) 2

n

3d

h 10

l

k

l

3

6 10 m

10

c

n

j 9

n m

6 h m

k

k

l7 i

h 7

i j

j 9

8

7 i

8

sablay-logo

FigureFigure 8.21 Two to Compare 8.21 Graphs Two 9 Graphs 8to Compare

3

Figure 8.21 Two Graphs to Compare

)

(a) 1 g

5 f

b

(a)

1

g a (a) 5a e ea 5 f 2 f bc b c c2

d4

4 3

3d

5(a)

(a)

5

g

!e

!

c d

1

3

c

2g f

4

c 1 e

e

! 1 b

g

(a)

a d

f

b

! 3 4

(a) 5 c

c

b g3 3 ! b e d1 d e i 2 f 4 4

1 c f ! a3 b a

d d 23

5

5 (b) (b) 6 6 g (b) g h n n 6 b m m 1 n 1 10 h 10 ! m! e k k i 10 i l7 updilseali l ! f f j k j i l 2 j 2 9 9 8

2 d 3 4 One Graph 2 8.22 Transforming One Graph into Another 4 Figure Figure 9 8.22 Transforming into Another

8

dcs-logo

Figure 8.22 Transforming One Graph into Another Discrete Mathematics for Computer Science

CS 30

acl-logo

offor (b)two shown in Figure 8.22 that the answer is yes. Drawings (a) in and (b), suggests are shown in Figure 8.21.answer Are they pictures of graphs, (b) shown Figure 8.22 suggests that the is yes. Matrix Representation of Graphs Graph Isomorphisms of the same graph? The transformation of the drawing of (a) into the drawing of (b) shown in Figure 8.22 suggests that the answer is yes. Compare there graphs (a)... (a) (b) (b) 1

(a) 1 5

g e

5

g

d4

4

d

4

a

e b f

2c

b c

a

g

e a5 f

f

6

1

2 b

(b) 2

n

3d

h 10

l

k

l

3

6 10 m

10

c

n

j 9

n m

6 h m

k

k

l7 i

h 7

i j

j 9

8

7 i

8

sablay-logo

FigureFigure 8.21 Two to Compare 8.21 Graphs Two 9 Graphs 8to Compare

3

Figure 8.21 Two Graphs to Compare

)

(a) 1 g

5 f

b

(a)

1

g a (a) 5a e ea 5 f 2 f bc b c c2

d4

4 3

3d

5(a)

(a)

5

g

!e

!

c d

1

3

c

2g f

4

c 1 e

e

! 1 b

g

(a)

a d

f

b

! 3 4

(a) 5 c

c

b g3 3 ! b e d1 d e i 2 f 4 4

1 c f ! a3 b a

d d 23

5

5 (b) (b) 6 6 g (b) g h n n 6 b m m 1 n 1 10 h 10 ! m! e k k i 10 i l7 updilseali l ! f f j k j i l 2 j 2 9 9 8

2 d 3 4 One Graph 2 8.22 Transforming One Graph into Another 4 Figure Figure 9 8.22 Transforming into Another

8

dcs-logo

Figure 8.22 Transforming One Graph into Another Discrete Mathematics for Computer Science

CS 30

acl-logo

offor (b)two shown in Figure 8.22 that the answer is yes. Drawings (a) in and (b), suggests are shown in Figure 8.21.answer Are they pictures of graphs, (b) shown Figure 8.22 suggests that the is yes. Matrix Representation of Graphs Graph Isomorphisms of the same graph? The transformation of the drawing of (a) into the drawing of (b) shown in Figure 8.22 suggests that the answer is yes. Compare there graphs (a)... (a) (b) (b) 1

(a) 1 5

g e

5

g

d4

4

d

4

a

e b f

2c

b c

a

g

e a5 f

f

6

1

2 b

(b) 2

n

3d

h 10

l

k

l

3

6 10 m

10

c

n

j 9

n m

6 h m

k

k

l7 i

h 7

i j

j 9

8

7 i

8

sablay-logo

FigureFigure 8.21 Two to Compare 8.21 Graphs Two 9 Graphs 8to Compare

3

Figure 8.21 Two Graphs to Compare

)

(a) 1 g

5 f

b

(a)

1

g a (a) 5a e ea 5 f 2 f bc b c c2

d4

4 3

3d

5(a)

(a)

5

g

!e

!

c d

1

3

c

2g f

4

c 1 e

e

! 1 b

g

(a)

a d

f

b

! 3 4

(a) 5 c

c

b g3 3 ! b e d1 d e i 2 f 4 4

1 c f ! a3 b a

d d 23

5

5 (b) (b) 6 6 g (b) g h n n 6 b m m 1 n 1 10 h 10 ! m! e k k i 10 i l7 updilseali l ! f f j k j i l 2 j 2 9 9 8

2 d 3 4 One Graph 2 8.22 Transforming One Graph into Another 4 Figure Figure 9 8.22 Transforming into Another

8

dcs-logo

Figure 8.22 Transforming One Graph into Another Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Denition Let

G = (VG , EG ) and H = (VH , EH ) be graphs. (a) A graph isomorphism from G to H , denoted f : G → H , is a pair of bijections FV : VG → VH and FE : EG → EH such that, for each e ∈ EG , the bijection fV maps the endpoints of e to the endpoints of fE (e ), both are more simply denoted by f .

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Denition Let

G = (VG , EG ) and H = (VH , EH ) be graphs. (a) A graph isomorphism from G to H , denoted f : G → H , is a pair of bijections FV : VG → VH and FE : EG → EH such that, for each e ∈ EG , the bijection fV maps the endpoints of e to the endpoints of fE (e ), both are more simply denoted by f . We say that G is isomorphic to H , written G ∼ = H , if there exists a graph isomorphism from G to H .

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Denition Let

G = (VG , EG ) and H = (VH , EH ) be graphs. (a) A graph isomorphism from G to H , denoted f : G → H , is a pair of bijections FV : VG → VH and FE : EG → EH such that, for each e ∈ EG , the bijection fV maps the endpoints of e to the endpoints of fE (e ), both are more simply denoted by f . We say that G is isomorphic to H , written G ∼ = H , if there exists a graph isomorphism from G to H .

sablay-logo

G and H are simple graphs, we can simply say that, G and H are isomorphic if there exists a one-to-one correspondence f : VG → VH such that {u , v } ∈ EG if and only if {f (u ), f (v )} ∈ EH .)

(If

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Denition Let

G = (VG , EG ) and H = (VH , EH ) be graphs. (a) A graph isomorphism from G to H , denoted f : G → H , is a pair of bijections FV : VG → VH and FE : EG → EH such that, for each e ∈ EG , the bijection fV maps the endpoints of e to the endpoints of fE (e ), both are more simply denoted by f . We say that G is isomorphic to H , written G ∼ = H , if there exists a graph isomorphism from G to H .

sablay-logo

G and H are simple graphs, we can simply say that, G and H are isomorphic if there exists a one-to-one correspondence f : VG → VH such that {u , v } ∈ EG if and only if {f (u ), f (v )} ∈ EH .)

(If

updilseal

graph automorphism on G is a graph isomorphism from G to itself. A nontrivial automorphism is an automorphism f : G → G that is not the identity map.

(b) A

Discrete Mathematics for Computer Science

CS 30

dcs-logo

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Isomorphism and Adjacency Matrices

1 2 (a) 3 4 5 6 7 (b) 8 9 10

1 0 1 1 2 1

2 1 0 0 0 0 6 0 1 0 0 1

3 1 0 0 1 1 7 1 0 1 2 1

4 2 0 1 0 0 8 0 1 0 0 0

5 1 0 1 0 0

sablay-logo

9 10 0 1 2 1 0 0 0 1 1 0

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Isomorphism and Adjacency Matrices

1 2 (a) 3 4 5 6 7 (b) 8 9 10

1 0 1 1 2 1

2 1 0 0 0 0 6 0 1 0 0 1

3 1 0 0 1 1 7 1 0 1 2 1

4 2 0 1 0 0 8 0 1 0 0 0

5 1 0 1 0 0 9 10 0 1 2 1 0 0 0 1 1 0

sablay-logo

7 8 10 9 6

7 0 1 1 2 1

8 10 9 6 1 1 2 1 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

us how to consistently order the vertices for (a) and (b) so that the corresponding Matrix Representation of Graphs adjacency matrices are the same. Graph Isomorphisms

Example (Equivalent Network Configurations). The two seemingly different network

E 8.20

configurations shown in Figure 8.25 have been proposed to implement a complex parallel program. Show that these networks are in fact the same configuration. 1

2

6

7

8

sablay-logo

3

4

5

9

Network G

10 Network H

Figure 8.25 Equivalent Computer Networks updilseal

Solution. The aim is to show that the corresponding graphs displayed in Figure 8.26 are isomorphic. Since G and H are simple graphs, it suffices to specify a vertex bijection f : VG â†’ VH that maps endpoints to endpoints and establishes an edge bijection between E G and E H . It is straightforward to check that defining f (1) = 9, f (2) = 10, f (3) = 7, f (4) = 6, and f (5) = 8 gives the Discrete Mathematics for Computer Science

CS 30

dcs-logo

acl-logo

raph, the edge mapping is completely determined by the vert Matrix Representation of Graphs Graph Isomorphisms

Example

are pictured what amount to two different ways of drawing omorphism f : K 4 â†’ H is given by K4

1

H

2

a

sablay-logo

f d 3

c

4

b

= a , f (2) = d, f (3) = c, and f (4) = b. Hence, K 4 âˆź = H. Moreo bels a , b, c, d on H are replaced by 1, 4, 3, 2, respectively, then e of H is seen to be an alternative drawing of K 4 . updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

tomorphism of K 4 is given by the graph isomorphis Matrix Representation of Graphs Graph Isomorphisms

Example

K4

1

2

sablay-logo

f 3

4

, f (2) = 4, f (3) = 1, and f (4) = 3. That is, f is the

updilseal

dcs-logo

1 2 3 4

Discrete Mathematics for Computer Science

CS 30

acl-logo

tomorphism of K 4 is given by the graph isomorphis Matrix Representation of Graphs Graph Isomorphisms

Example

K4

1

2

sablay-logo

f 3

4

A graph G = (V , E ) is said to be vertex transitive if, for any u , v âˆˆ V . , f (2) = 4, f (3) = 1, and f (4) = 3. That is, f is the there is a graph automorphism f such that f (u ) = v .

updilseal

dcs-logo

1 2 3 4

Discrete Mathematics for Computer Science

CS 30

acl-logo

For any positive integer n, the complete graph K n is easily seen to be vertex Matrix Representation of Graphs transitive. The point is that, for K n , graph automorphisms correspond to perGraph Isomorphisms mutations of {1, 2, . . . , n}. For instance, the automorphism in Example 8.21(b) Example can be thought of as an isomorphism f constructed to send u = 1 to v = 2. ■

8.22

8.23

M 8.4

Displayed are three different drawings of a graph known as the Petersen graph. Verification that these graphs are indeed isomorphic is left for the exercises. 1

5

11 6

10 9 4

2

7 8

15

12

17

16

13

19

20

22

18

26 28 27

30

That the Petersen graph is vertex transitive is also left for the exercises. Graph Isomorphism Is an Equivalence Relation

sablay-logo

23

24 29

14 3

21

25

■ updilseal

For all graphs G, H, and K , (a) G ∼ = G. (b) if G ∼ = G. = H, then H ∼ (c) if G ∼ = K. = K , then G ∼ = H and H ∼

Discrete Mathematics for Computer Science

dcs-logo

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

How does one prove that two graphs are not isomorphic?

If for each graph G , we assign a value i (G ) in such a way that, for any two isomorphic graphs G and H , we have i (G ) = i (H ), then we say that i is a graph invariant. That is, graph invariants are preserved under isomorphisms.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

How does one prove that two graphs are not isomorphic?

If for each graph G , we assign a value i (G ) in such a way that, for any two isomorphic graphs G and H , we have i (G ) = i (H ), then we say that i is a graph invariant. That is, graph invariants are preserved under isomorphisms. Consequently, if for two graphs G and H and some invariant i , we have i (G ) 6= i (H ), then we can conclude that G âˆź 6 H. =

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Example

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Example

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Example

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Isomorphism and Directed Graphs

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Graph Isomorphism and Directed Graphs

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo

Matrix Representation of Graphs Graph Isomorphisms

Questions?

sablay-logo

See you next meeting!

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo