What is Cyclomatic complexity?
[[File: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.]] '''Cyclomatic complexity''' is a measurement to see how difficult a [[computer program]] is to understand. The measurement was developed by [[Thomas J. McCabe, Sr.]] in 1976. It looks at the program's source code and measures the number of independent paths through the source code. The concept is similar to the general text complexity, which is measured by the [[Flesch-Kincaid Readability Test]]. Cyclomatic complexity is computed using the [[control flow graph]] of the program: the nodes of the [[Graph (mathematics)|graph]] correspond to indivisible groups of commands of a program, and a [[Directed graph|directed]] edge connects two nodes if the second command might be executed immediately after the first command. Cyclomatic complexity may also be applied to individual [[function (computer science)|functions]], [[modular programming|modules]], [[method (computer science)|methods]] or [[class (computer science)|classes]] within a program. One [[software testing|testing]] strategy, called [[Basis path testing]] by McCabe who first proposed it, is to test each linearly independent path through the program; in this case, the number of test cases will equal the cyclomatic complexity of the program.<ref>{{cite web| url=http://users.csc.calpoly.edu/~jdalbey/206/Lectures/BasisPathTutorial/index.html| title=Basis Path Testing| author=A J Sojev}}</ref> ==References== {{reflist}} [[Category:Theoretical computer science]]