Question

Consider an undirected graph GG where self-loops are not allowed. The vertex set of GG is {(i,j):1≤i≤12,1≤j≤12}\{(i, j): 1 \le i \le 12, 1 \le j \le 12\}. There is an edge between (a,b)(a, b) and (c,d)(c, d) if ∣a−c∣≤1|a - c| \le 1 and ∣b−d∣≤1|b - d| \le 1. The number of edges in this graph is __________.

Official answer and solution
Official answer
506
From
Official GATE 2014 answer key

Solution

Count horizontal, vertical, and diagonal edges in the 12x12 grid graph, or sum vertex degrees and apply the Handshaking Lemma.

The graph GG consists of vertices (i,j)(i, j) for 1≤i,j≤121 \le i, j \le 12, forming a 12×1212 \times 12 grid with 144144 vertices.
An edge exists between (a,b)(a, b) and (c,d)(c, d) if ∣a−c∣≤1|a - c| \le 1 and ∣b−d∣≤1|b - d| \le 1 (excluding self-loops).

Let us count edges by category:

  1. Horizontal edges:
    Each of the 12 rows contains 12−1=1112 - 1 = 11 horizontal edges.

    Horizontal edges=12×11=132\text{Horizontal edges} = 12 \times 11 = 132
  2. Vertical edges:
    Each of the 12 columns contains 12−1=1112 - 1 = 11 vertical edges.

    Vertical edges=12×11=132\text{Vertical edges} = 12 \times 11 = 132
  3. Diagonal edges:
    The grid has (12−1)×(12−1)=11×11=121(12 - 1) \times (12 - 1) = 11 \times 11 = 121 unit squares.
    Each unit square contains 2 diagonal edges:

    • One leading diagonal (slope +1+1)
    • One trailing diagonal (slope −1-1)
    Diagonal edges=2×121=242\text{Diagonal edges} = 2 \times 121 = 242

Total number of edges in GG:

Total Edges=132+132+242=506\text{Total Edges} = 132 + 132 + 242 = 506

Verification via Handshaking Lemma:

  • 4 corner vertices each have degree 3: 4×3=124 \times 3 = 12
  • 4×10=404 \times 10 = 40 boundary non-corner vertices each have degree 5: 40×5=20040 \times 5 = 200
  • 10×10=10010 \times 10 = 100 interior vertices each have degree 8: 100×8=800100 \times 8 = 800
∑deg(v)=12+200+800=1012\sum \text{deg}(v) = 12 + 200 + 800 = 1012
∣E∣=10122=506|E| = \frac{1012}{2} = 506
Final answer

506

Common trap

Omitting the diagonal edges and counting only the grid mesh edges (132+132=264132 + 132 = 264).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
61 of 65, printed as CS Q.51
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.