Cyclomatic Complexity
Cyclomatic Complexity
complexity
Cyclomatic complexity is a software engineering metric that was introduced by Thomas J.
McCabe in 1976. This metric is a numerical score that represents the number of different
paths a program can take during its execution.
A higher score means more execution paths (higher complexity), while a lower score means
fewer paths (lower complexity).
C = E - N + 2P
•if (age > 60)
•else if (membershipDuration > 5).
C = E - N + 2P
= 8 - 7 + 2(1)
=3
IF X = 300 THEN
IF Y > Z
THEN X = Y
ELSE X = Z
END IF END
IF PRINT X
V(G) = E - N + 2 * P = 8 - 7 + 2 * 1 = 3