Free · Other calculators
Control-Flow Graph Cyclomatic Complexity
Calculate McCabe’s control-flow complexity from edge, node and connected-component counts.
- Formula & worked example
- Private in your browser
- No signup
Calculator inputs
Loading calculator…
How to use this calculator
- Enter the known values in the units shown. Results update as you type.
- Where results are editable, change one to solve backwards. Lock a value to hold it fixed.
- Use the worked example to check the method. Reset restores the starting fields.
Private by default
Inputs and results stay in this browser tab. Bookify does not upload or store the values you enter.
Formula and method
A connected control-flow graph with 8 edges and 7 nodes has complexity 8 − 7 + 2 = 3.
McCabe complexity = edges − nodes + 2 × connected components
Worked example
Enter these known values and leave the other values blank.
- Connected control-flow components
- 1
- Directed control-flow edges
- 8
- Control-flow nodes
- 7
- McCabe cyclomatic complexity
- 3
Assumptions and limitations
- Counts are whole numbers. Nodes and components are positive, edges are nonnegative, components cannot exceed nodes, and edges must be at least nodes minus components.
- Use control-flow graphs with the appropriate entry/exit convention. For several disconnected components this formula sums the E − N + 2 measure for each component.
- The tool checks count consistency, not the graph itself. Complexity concerns independent control-flow paths; it is not the total number of possible executions or proof of test adequacy.
Common questions
Why is a straight-line connected routine’s value one?
Its control-flow graph has one fewer edge than nodes, so E − N + 2 equals one.
Is this the ordinary graph cycle-rank formula?
The ordinary cycle rank is E − N + C. The control-flow complexity convention here is E − N + 2C, with one additional basis path per component.
References
Bookify requires components no greater than nodes and enough edges to connect each component.