WBJECA 2025 — Computer PYQ
WBJECA | Computer | 2025In a graph of n nodes and n edges, how many cycles will be present?
Choose the correct answer:
- A.
Exactly 1
- B.
At most 1
- C.
At most 2
- D.
Depends on the graph
(Correct Answer)
Depends on the graph
Explanation
In graph theory, the number of cycles in a graph is not fixed solely by the number of nodes (n) and edges (n). It depends entirely on the structure and connectivity of the graph.
To understand this, let's look at the properties of a graph where the number of edges equals the number of nodes (∣E∣=∣V∣=n):
Case 1: Connected Graph. If the graph is connected and contains exactly n nodes and n edges, it is known as a unicyclic graph. By definition, such a graph contains exactly one cycle.
Case 2: Disconnected Graph. If the graph is disconnected, it may consist of multiple components. Some components might be trees (zero cycles), while others might contain one or more cycles. For example, you could have one component that is a cycle and another that is a tree, or even a component that contains two cycles while another component is just an isolated vertex.
We can express the relationship between the number of edges (E), nodes (V), and connected components (C) using the following formula for a forest (a collection of trees):
E=V−C
When E=V, the cyclomatic complexity (M) of the graph—which represents the number of independent cycles—is given by:
M=E−V+C
Substituting E=V:
M=V−V+C=C
Since the number of components (C) can vary based on how the graph is constructed, the number of cycles is not constant. Therefore, the answer (D) Depends on the graph is correct because it acknowledges that the count of cycles is dependent on the graph's connectivity and structure.

