All mock tests are FREE till 31 December — register to save your progress

The cyclomatic complexity of a flow graph V(G), in terms of predicate nodes, is: [where P is the number of predicate nodes in the flow graph V(G)]

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. P + 1

Explanation

McCabe's cyclomatic complexity can be computed three equivalent ways: V(G) = E – N + 2 (edges, nodes), V(G) = number of enclosed regions of the planar flow graph, and V(G) = P + 1, where P counts the predicate (decision) nodes. Each predicate node adds exactly one binary branch and therefore one more linearly independent path, so starting from a single straight-line path the count grows to P + 1. For example, a program with three simple if-statements and no other branching has V(G) = 3 + 1 = 4 independent paths, which is also the minimum number of basis-path test cases required.

More System Software and Operating System questions