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
Official answer and solution
- Official answer
- D
- From
- Official GATE 2022 answer key
Solution
Use the property that counts the number of closed walks of length starting and ending at vertex .
In a simple undirected graph, the -th entry of gives the number of closed walks of length 3 starting and ending at vertex .
In a simple graph (which has no self-loops and no multi-edges), any closed walk of length 3 must visit three distinct vertices forming a triangle (3-cycle).
For a specific triangle formed by vertices :
- There are 2 closed walks starting at vertex : and .
- Similarly, there are 2 closed walks starting at vertex , and 2 closed walks starting at vertex .
Thus, each triangle contributes exactly closed walks of length 3 to the total sum of the diagonal elements .
Therefore, the number of triangles (3-cycles) in the graph is .
Option (D)
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.