Adjacency Matrix & Graph Isomorphism
This post will briefly go over the definition of adjacency matrix for graphs, some related theorems regarding graph isomorphism, and some proofs.
Adjacency Matrix
- The adjacency matrix is one way to formally represent a graph, for example in convenience for computer computation.
- Given a graph G : = ( V , E ) G:=(V,E) G:=(V,E), where ∣ V ∣ = n |V|=n ∣V∣=n, to obtain the adjacency matrix of this graph, we firstly select an ordering of the vertices, say we (re)name them as v 1 , . . . , v n v_1,...,v_n v1,...,vn.
- Next, we label the rows and columns of a matrix with the ordered vertices.
- The entry in this matrix in row $i4, column j j j, when i ≠ j i \ne j i=j, is the number of edges incident on i i i and j j j.
- If i = j i = j i=j, the entry is twice the number of loops incident on i i i, and this is because we want the nice formula ∑ i = 1 n δ ( v i ) = 2 ∣ E ∣ , n ≥ 1 \sum_{i=1}^n\delta(v_i)=2|E| ,n≥1 ∑i=1nδ(vi)=2∣E∣,n≥1 to hold in general ( n = 0 n=0 n=0 is not particuarly interesting).
Remark
- Besides entries on the main diagonal, the information are redundantly stored twice in the adjacency matrix (the information above the main diagonal is identical to the information below the main diagonal). Therefore, to obtain δ ( v i ) \delta(v_i) δ(vi), we sum up all the entries in the i i ith row OR all the entries in the i i ith column, but never both.
Reordering the Vertices
- Ordering affects which row represents which vertex. Observe that if a graph has n n n vertices, we have n ! n! n! ways to reorder the vertices, and we can thus produce n ! n! n! (not necessarily distinct) adjacency matrices.
Graph Isomorphism and Adjacency Matrix
Proposition
- Two graphs G 1 , G 2 G_1,G_2 G1,G2 are isomorphic iff there is some ordering of their vertices so that A 1 = A 2 A_1=A_2 A1=A2 ( A 1 A_1 A1 is an adjacency matrix of G 1 G_1 G1, and A 2 A_2 A2 is an adjacency matrix of G 2 G_2 G2).
Proof
Isomorphism ⟹ \implies ⟹Ordering
- Suppose G 1 , G 2 G_1,G_2 G1,G2 are isomorphic, then there exist bijections f : V 1 → V 2 f:V_1\to V_2 f:V1→V2 and g : E 1 → E 2 g:E_1\to E_2 g:E1→E2 such that e ∈ E 1 e\in E_1 e∈E1 is incident on v , w ∈ V 1 v,w\in V_1 v,w∈V1 iff g ( e ) ∈ E 2 g(e)\in E_2 g(e)∈E2 is incident on f ( v ) , f ( w ) ∈ V 2 f(v),f(w)\in V_2 f(v),f(w)∈V2.
- Thus, we can choose arbitrarily an ordering of the vertices of G 1 G_1 G1, say v 1 , . . . , v n v_1,...,v_n v1,...,vn, which gives us an adjacency matrix of G 1 G_1 G1, A 1 A_1 A1. Since f f f is a bijection, we can let the ordering of vertices of G 2 G_2 G2 be f ( v 1 ) , . . . , f ( v n ) f(v_1),...,f(v_n) f(v1),...,f(vn), and this gives us A 2 A_2 A2.
- Now in A 1 A_1 A1, when i ≠ j i≠j i=j, A 1 i j {A_1}_{ij} A1ij represents the number of edges incident on v i , v j v_i,v_j vi,vj, say k k k, so e 1 , . . . , e k ∈ E 1 e_1,...,e_k\in E_1 e1,...,ek∈E1 are incident on v i , v j v_i,v_j vi,vj. In A 2 A_2 A2, A 2 i j {A_2}_{ij} A2ij represents the number of edges incident on f ( v i ) , f ( v j ) f(v_i),f(v_j) f(vi),f(vj), and since e 1 , . . . , e k ∈ E 1 e_1,...,e_k\in E_1 e1,...,ek∈E1 are incident on v i , v j v_i,v_j vi,vj, g ( e 1 ) , . . . , g ( e k ) ∈ E 2 g(e_1),...,g(e_k)\in E_2 g(e1),...,g(ek)∈E2 must also be incident on f ( v i ) , f ( v j ) f(v_i),f(v_j) f(vi),f(vj) by the definition of isomorphism.
- Alternatively, we can argue that A 2 i j = l {A_2}_{ij}=l A2ij=l, then e 1 ′ , . . . , e l ′ ∈ E 2 e'_1,...,e'_l\in E_2 e1′,...,el′∈E2 are incident on f ( v i ) , f ( v j ) f(v_i),f(v_j) f(vi),f(vj). Then, we use the fact that since g g g is a bijection, the inverse g − 1 : E 2 → E 1 g^{-1}:E_2\to E_1 g−1:E2→E1 exists and is a bijection. Therefore, g − 1 ( e 1 ′ ) , . . . , g − 1 ( e l ′ ) ∈ E 1 g^{-1}(e'_1),...,g^{-1}(e'_l) \in E_1 g−1(e1′),...,g−1(el′)∈E1 are incident on v i , v j ∈ V 1 v_i,v_j\in V_1 vi,vj∈V1, which means l = k l=k l=k.
- For the diagonal entries, the proof is essentially the same, but be careful when writing the numbers because you have to double the number of loops in those entries.
- Thus, we found such orderings so that the adjacency matrices are exactly the same.
Ordering ⟹ \implies ⟹Isomorphism - Suppose there exist orderings of vertices in G 1 G_1 G1 and vertices of G 2 G_2 G2 such that A 1 = A 2 A_1=A_2 A1=A2. As A 1 A_1 A1 and A 2 A_2 A2 are equal, they are equal in size, so G 1 , G 2 G_1,G_2 G1,G2 have the same number of vertices. Let the ordersing be v 1 , . . , v n ∈ V 1 v_1,..,v_n\in V_1 v1,..,vn∈V1 and v 1 ′ , . . . , v n ′ ∈ V 2 v'_1,...,v'_n\in V_2 v1′,...,vn′∈V2 respectively.
- Define f : V 1 → V 2 f:V_1\to V_2 f:V1→V2 by f ( v 1 ) = v 1 ′ , . . , f ( v n ) = v n ′ f(v_1)=v'_1,..,f(v_n)=v'_n f(v1)=v1′,..,f(vn)=vn′. F F F is a function because it is defined everywhere on V 1 V_1 V1, and each v i ∈ V 1 v_i\in V_1 vi∈V1 corresponds to a unique v i ′ ∈ V 2 v'_i\in V_2 vi′∈V2 as the vertices are all distinct. Moreover, f f f is injective because if i ≠ j i≠j i=j, then f ( v i ) ≠ f ( v j ) f(v_i)≠f(v_j) f(vi)=f(vj) as the vertices are distinct; f f f is also surjective because if v i ′ ∈ V 2 v'_i\in V_2 vi′∈V2, then due to how we defined the function in the first place, f ( v i ) = v i ′ f(v_i)=v'_i f(vi)=vi′. Thus, f f f is a bijection.
- We then define g : E 1 → E 2 g:E_1\to E_2 g:E1→E2. When i ≠ j i≠j i=j, suppose A 1 i j = k {A_1}_{ij}=k A1ij=k, then ∃ \exist ∃ distinct e 1 , . . , e k ∈ E 1 e_1,..,e_k\in E_1 e1,..,ek∈E1 that are incident on v i , v j ∈ V 1 v_i,v_j\in V_1 vi,vj∈V1, and because A 1 = A 2 A_1=A_2 A1=A2, A 2 i j = k {A_2}_{ij}=k A2ij=k, so ∃ \exists ∃ distinct $ e 1 ′ , . . , e k ′ ∈ E 2 e'_1,..,e'_k\in E_2 e1′,..,ek′∈E2 that are incident on v i ′ = f ( v i ) , v j ′ = f ( v j ) v'_i=f(v_i),v'_j=f(v_j) vi′=f(vi),vj′=f(vj). Thus, we can define g ( e 1 ) = e 1 ′ , . . , g ( e k ) = e k ′ g(e_1)=e'_1,..,g(e_k)=e'_k g(e1)=e1′,..,g(ek)=ek′. To avoid re-definitions, we restrict i = 1 , . . . , n − 1 i=1,...,n-1 i=1,...,n−1 and j = 2 , . . . , n j=2,...,n j=2,...,n (i.e. all entries above the main diagonal).
- When i = j i=j i=j, if A 1 i j = l {A_1}_{ij}=l A1ij=l, we know we have distinct loops e 1 , . . , e l 2 ∈ E 1 e_1,..,e_{\frac{l}{2}}\in E_1 e1,..,e2l∈E1 incident on v i ∈ V 1 v_i\in V_1 vi∈V1, and thus we also have distinct e 1 ′ , . . . , e l 2 ′ ∈ E 2 e'_1,...,e'_{\frac{l}{2}}\in E_2 e1′,...,e2l′∈E2 incident on v i ′ = f ( v i ) ∈ V 2 v'_i=f(v_i)\in V_2 vi′=f(vi)∈V2. Thus, we define g ( e 1 ) = e 1 ′ , . . . , g ( e l 2 ) = e l 2 ′ g(e_1)=e'_1,...,g(e_{\frac{l}{2}})=e'_{\frac{l}{2}} g(e1)=e1′,...,g(e2l)=e2l′.
- g g g is a bijection naturally from our definition.
- Thus, ( f , g ) (f,g) (f,g) gives an isomorphism, which establishes the proposition.
Remark
- This propistion allow us to prove or disprove two graphs are isomorphic by enumerating all their adjacency matrices and see if we find an euqal pair or not.
Isomorphism for Simple Graphs
We will be using the proposition proved above to prove the following theorem about simple graphs’ isomorphism.
Theorem
- Let
G
1
G_1
G1 and
G
2
G_2
G2 be simple graphs. The following are equivalent:
- (a) G 1 G_1 G1 and G 2 G_2 G2 are isomorphic.
- (b) There is a one-to-one, onto function f from the vertex set of G 1 G_1 G1 to the vertex set of G 2 G_2 G2 satisfying the following: Vertices v v v and w w w are adjacent in G 1 G_1 G1 if and only if the vertices f ( v ) f(v) f(v) and f ( w ) f(w) f(w) are adjacent in G 2 G_2 G2 .
Proof
(a) ⟹ \implies ⟹(b)
- Follows the definition of graph isomorphism.
(b) ⟹ \implies ⟹(a)
- Suppose we have such a bijection f f f. It implies that ∣ V 1 ∣ = ∣ V 2 ∣ |V_1|=|V_2| ∣V1∣=∣V2∣ because a bijection between two (finite) sets exists if and only if the sets have the same cardinality (by the definition of two sets having the same cardinality). Therefore, we can choose the ordering of V 1 V1 V1 to be ( v 1 , . . . , v n ) (v_1,...,v_n) (v1,...,vn) and thus ( f ( v 1 ) , . . . , f ( v n ) ) (f(v_1),...,f(v_n)) (f(v1),...,f(vn)) is an ordering of V 2 V_2 V2.
- Let A 1 A_1 A1 be the adjacency matrix of G 1 G_1 G1 relative to the first ordering stated above and A 2 A_2 A2 of G 2 G_2 G2 to the second. Because there is no loops or parallel edges in G 1 , G 2 G_1, G_2 G1,G2, each entry in any of the adjacency matrices for G 1 G_1 G1 and G 2 G_2 G2 is either 0 0 0 or $1. Thus, since f f f satisfies vertices v v v and w w w are adjacent in G 1 G_1 G1 if and only if the vertices f ( v ) f(v) f(v) and f ( w ) f(w) f(w) are adjacent in G 2 G_2 G2, A 1 = A 2 A_1=A_2 A1=A2, so isomorphism follows the proposition.