Definition

Email this page to a friend   

Email to a friend

McCabe Cyclomatic Complexity

(Alias: McCabe number)

Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.
             - Alan Perlis, American Scientist

McCabe's cyclomatic complexity is a software quality metric that quantifies the complexity of a software program. Complexity is inferred by measuring the number of linearly independent paths through the program. The higher the number the more complex the code.

The Significance of the McCabe Number

Measurement of McCabe's cyclomatic complexity metric ensures that developers are sensitive to the fact that programs with high McCabe numbers (e.g. > 10) are likely to be difficult to understand and therefore have a higher probability of containing defects. The cyclomatic complexity number also indicates the number of test cases that would have to be written to execute all paths in a program.

Calculating the McCabe Number

Cyclomatic complexity is derived from the control flow graph of a program as follows:

Cyclomatic complexity (CC) = E - N + 2P
Where:
P = number of disconnected parts of the flow graph (e.g. a calling program and a subroutine)
E = number of edges (transfers of control)
N = number of nodes (sequential group of statements containing only one transfer of control)

Examples of McCabe Number Calculations

McCabe Number Calc
Collaboration

Member Comments

24 Comments 

19 member ratings

✭ ✭ ✭ ✭ ✩

RE Definition: McCabe Cyclomatic Complexity

Nice explanation of McCabe Cyclomatic Complexity

By FrankTornado » Thu 13-Jan-2022, 20:07, My rating: ✭ ✭ ✭ ✭ ✭

I looked everywhere for an explanation for McCabe Cyclomatic Complexity, it was hard for me to understand it. I even looked at various blogs like this one - https://www.austadiums.com/news/1113/nrl-plans-to-build-a-new-western-sydney-stadium.
But you know, it was on this site that I found a sensible explanation of this complexity. I found it so interesting and in pictures that I even decided to leave a comment! Thank you!

24 Comments  • Page 10 of 24 •        Previous « 1…  8   9   10   11   12  …24 » Next

- Rate this definition.
- Did it help?
- Suggest improvements.
- Request more information.
- Exchange ideas with our member community.

Email to a friend