Cyclomatic Complexity Measures:
McCabe proposed the cyclomatic number, V (G) of graph theory as an indicator of software complexity. The cyclomatic number is equal to the number of linearly independent paths through a program in its graph representation.
Cyclomatic complexity can be used in two ways, to:
- Limit code complexity.
- Determine the number of test cases required.
Cyclomatic complexity can be one of the most difficult software quality metrics to understand. And that makes it difficult to calculate.
For a program control graph G, cyclomatic number, V (G), is given as:
V (G) = E - N + 2 * P
E = The number of edges in graphs G
N = The number of nodes in graphs G
P = The number of connected components in graph G.
Properties:
- V (G) is the maximum number of independent paths in the graph
- V (G) >=1
- G will have one path if V (G) = 1
- Minimize complexity to 10
Example:
Another Example:
Advantages:
- Gives complexity of various designs
- Computed early in life cycle
- Easy to apply
- Measures minimum effort
Disadvantages:
- Measures program’s control complexity and not the data complexity
- Nested conditional structures are harder to understand
- Ignore the size of the program
0 Comments