## Monday, April 20, 2009

### Explain Cyclomatic Complexity.

Cyclomatic Complexity

Cyclomatic complexity is used to measure the complexity of a program. It directly measures the number of linearly independent paths through a program's source code. The greater the number of paths through a module, the higher the complexity. Cyclomatic complexity is based on classic graph theory in which the Cyclomatic number of graph, denoted by V(g), is calculated by counting the number of linearly independent paths within a program. Cyclomatic number of graph also allows you to determine the minimum number of unique tests that must be run in order to execute every executable statement. A module is defined as a set of executable code that has one entrance and one exit.

Cyclomatic complexity can be calculated in two ways:

By counting the nodes and edges of a graph:
V (g) = e-n+2, e is the number of edges and n is the number of nodes.

By counting the number of binary decision points:
V (g) =b+1, where b is the number of binary decisions in the control graph. If there is n-way decision then it is counted as n-1 decisions.

g is the control graph.

Interesting resources on Cyclomatic Complexity

Cyclomatic Complexity resource 1
CC

Cyclomatic Complexity resource 2
CC

Cyclomatic Complexity resource 3
CC

Cyclomatic Complexity resource 4
CC

Cyclomatic Complexity resource 5
CC

Cyclomatic Complexity resource 6
CC