Mccabe's Cyclomatic Complexity: Calculate with Flow Graph (Example)

To understand Cyclomatic Complexity, lets first understand -

What is Software Metric?

Measurement is nothing but quantitative indication of size / dimension / capacity of an attribute of a product / process. Software metric is defined as a quantitative measure of an attribute a software system possesses with respect to Cost, Quality, Size and Schedule.

Example-

Measure - No. of Errors
Metrics - No. of Errors found per person

In this tutorial, you will learn-

Cyclomatic Complexity in Software Testing

Cyclomatic Complexity in Software Testing is a testing metric used for measuring the complexity of a software program. It is a quantitative measure of independent paths in the source code of a software program. Cyclomatic complexity can be calculated by using control flow graphs or with respect to functions, modules, methods or classes within a software program.

Independent path is defined as a path that has at least one edge which has not been traversed before in any other paths.

This metric was developed by Thomas J. McCabe in 1976 and it is based on a control flow representation of the program. Control flow depicts a program as a graph which consists of Nodes and Edges.

In the graph, Nodes represent processing tasks while edges represent control flow between the nodes.

 

YOU MIGHT LIKE: