The cyclomatic complexity of the following graph is –
2021
The cyclomatic complexity of the following graph is –

Answer: B. 5 — Concept. McCabe's cyclomatic complexity V(G) counts the linearly independent paths through a program graph. For a graph with E edges, N nodes and P connected…
- A.
4
- B.
5
- C.
7
- D.
6
Attempted by 260 students.
Show answer & explanation
Correct answer: B
Concept. McCabe's cyclomatic complexity V(G) counts the linearly independent paths through a program graph. For a graph with E edges, N nodes and P connected components, V(G) = E − N + 2P, which becomes V(G) = E − N + 2 when the graph is a single connected component. Equivalently, a planar drawing of such a graph is divided into exactly V(G) regions, counting the unbounded outer region.
Applying this to the graph shown.
Count the nodes. The vertices drawn are a, b, c, d, e and f, so N = 6.
Count the edges, one per arrow: a → b, a → c, c → b, c → e, b → d, d → b, e → d, e → f and f → d. The vertices b and d are joined by two arrows pointing opposite ways, and each arrow is its own edge, so E = 9.
The whole drawing is one connected component, so P = 1 and the formula reduces to V(G) = E − N + 2.
Substitute the counts: V(G) = 9 − 6 + 2 = 5.
Cross-check by regions. The drawing has no crossing lines, so its regions can be counted directly: the a-b-c cycle, the two-arrow loop between b and d, the area bounded by b, c, e and d, and the d-e-f cycle give 4 bounded regions, and the outer region makes 5. The cycle-space form (E − N + 1) + 1 = (9 − 6 + 1) + 1 = 5 agrees.
A common slip. Reading the two arrows between b and d as a single edge gives E = 8 and V(G) = 8 − 6 + 2 = 4, so each arrow must be counted separately.
Hence the cyclomatic complexity of the graph is 5.