Which one of the following is used to compute cyclomatic complexity?
Show answerHide answer
Correct answer: (D) P + 1, where P is the number of predicate nodes in the flow graph G.
Explanation
Cyclomatic complexity measures the logical complexity of a program (the number of independent paths). It can be computed as: (1) the number of regions of the flow graph; (2) V(G) = E – N + 2, where E is the number of edges and N the number of nodes; (3) V(G) = P + 1, where P is the number of predicate nodes in the flow graph G.