Content deleted Content added
Undid revision 933659073 by Potterypriya (talk) |
→Definition: Added brief definition of "linearly independent" paths in a digraph |
||
Line 13:
=== Definition ===
[[Image:control flow graph of function with loop and an if statement without loop back.svg|thumb|250px|right|A control flow graph of a simple program. The program begins executing at the red node, then enters a loop (group of three nodes immediately below the red node). On exiting the loop, there is a conditional statement (group below the loop), and finally the program exits at the blue node. This graph has 9 edges, 8 nodes, and 1 [[connected component (graph theory)|connected component]], so the cyclomatic complexity of the program is 9 - 8 + 2*1 = 3.]]
The cyclomatic complexity of a section of [[source code]] is the number of linearly independent [[
Mathematically, the cyclomatic complexity of a [[Structured programming|structured program]]{{efn|1=Here "structured" means in particular "with a single exit ([[return statement]]) per function".}} is defined with reference to the [[control flow graph]] of the program, a [[directed graph]] containing the [[basic block]]s of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity '''M''' is then defined as<ref name="mccabe76">{{cite journal| last=McCabe|date=December 1976| journal=IEEE Transactions on Software Engineering|issue=4| pages=308–320|
|