Cyclomatic complexity: Difference between revisions

Content deleted Content added
Undid revision 869230639 by 112.196.19.18 (talk)
Fixed the link
Line 27:
[[Image:control flow graph of function with loop and an if statement.svg|thumb|250px|The same function as above, represented using the alternative formulation, where each exit point is connected back to the entry point. This graph has 10 edges, 8 nodes, and 1 [[connected component (graph theory)|connected component]], which also results in a cyclomatic complexity of 3 using the alternative formulation (10 - 8 + 1 = 3).]] <!-- Do not change this to 4. This has been done twice, but 3 is the correct answer. Read the paragraph below for the explanation of why: -->
 
An alternative formulation is to use a graph in which each exit point is connected back to the entry point. In this case, the graph is [[strongly connected]], and the cyclomatic complexity of the program is equal to the [[cyclomatic number]] of its graph (also known as the [[Betti number#Example 2: the first Betti number in graph theory|first Betti number]]), which is defined as<ref name="mccabe76" />
:''M'' = ''E'' &minus; ''N'' + ''P''.