N is the number of nodes of the control flow graph and E is the number of…

2021

N is the number of nodes of the control flow graph and E is the number of edges in the control flow graph. What is McCabe’s cyclomatic complexity V(G)?

  1. A.

    V(G) = E + N + 2

  2. B.

    V(G) = E − N + 2

  3. C.

    V(G) = E + N − 2

  4. D.

    V(G) = E − N − 2

Attempted by 349 students.

Show answer & explanation

Correct answer: B

McCabe’s cyclomatic complexity V(G) is a measure of the number of linearly independent paths in a program’s control flow graph. It is calculated using the formula:

V(G) = E - N + 2

Where: E = number of edges in the control flow graph, N = number of nodes in the control flow graph.

This formula is derived from graph theory, where the complexity represents the number of regions in the graph. The +2 accounts for the entry and exit points of the control flow.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs