Question

Consider a simple undirected unweighted graph with at least three vertices. If A is the adjacency matrix of the graph, then the number of 3-cycles in the graph is given by the trace of

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2022 answer key

Solution

Use the property that (Ak)ii(A^k)_{ii} counts the number of closed walks of length kk starting and ending at vertex ii.

In a simple undirected graph, the (i,i)(i, i)-th entry of A3A^3 gives the number of closed walks of length 3 starting and ending at vertex ii.

In a simple graph (which has no self-loops and no multi-edges), any closed walk of length 3 must visit three distinct vertices i,j,ki, j, k forming a triangle (3-cycle).

For a specific triangle formed by vertices {u,v,w}\{u, v, w\}:

  • There are 2 closed walks starting at vertex uu: u→v→w→uu \to v \to w \to u and u→w→v→uu \to w \to v \to u.
  • Similarly, there are 2 closed walks starting at vertex vv, and 2 closed walks starting at vertex ww.

Thus, each triangle contributes exactly 2×3=62 \times 3 = 6 closed walks of length 3 to the total sum of the diagonal elements tr(A3)=∑i(A3)ii\text{tr}(A^3) = \sum_i (A^3)_{ii}.

Therefore, the number of triangles (3-cycles) in the graph is tr(A3)6\frac{\text{tr}(A^3)}{6}.

Final answer

Option (D)

Common trap

Dividing by 3 instead of 6, forgetting that each triangle can be traversed in both clockwise and counter-clockwise directions.

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

Source

Paper
GATE 2022 Computer Science and Information Technology (CS)
Question
37 of 65
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.