Consider an undirected graph G where self-loops are not allowed. The vertex set of G is {(i, j) : 1 <= i <= 12, 1 <= j <= 12}. There is an edge between (a, b) and (c, d) if |a - c| <= 1 and |b - d| <= 1. The number of edges in this graph is ______.
GATE 2014 · Discrete Mathematics · Graph Connectivity · medium
Answer: 506
Count horizontal edges: Each of the 12 rows has 11 adjacent pairs (columns 1-2, 2-3, ..., 11-12). Horizontal edges = 12 * 11 = 132.
Count vertical edges: Each of the 12 columns has 11 adjacent pairs. Vertical edges = 12 * 11 = 132.
Count diagonal edges (both directions): Each 2x2 sub-square (there are 11*11 = 121 of them) contributes 2 diagonal edges: one going down-right and one going down-left. Diagonal edges = 2 * 11 * 11 = 242.