CS FundamentalsHardGATE CS · product placement

McCabe's V(G) = E - N + 2 for one function comes from the cyclomatic number of a strongly connected graph, E - N + P. Where does the '+2' come from?

  1. A. One for the entry node and one for the exit node
  2. B. A virtual edge is added from the exit back to the entry to make the graph strongly connected, so (E + 1) - N + 1
  3. C. It is an empirical correction for unstructured code such as goto
  4. D. It counts the true and false outcomes of the first decision

Correct answer: B. A virtual edge is added from the exit back to the entry to make the graph strongly connected, so (E + 1) - N + 1

Adding one back edge makes the graph strongly connected with E + 1 edges and P = 1 component, giving (E + 1) - N + 1 = E - N + 2. For P separate functions the formula becomes E - N + 2P.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic