Cyclomatic complexity is a software metric used to find the number of independent execution paths in the application. It was introduced by Thomas McCabe in 1976.

Cyclomatic complexity defines the number of linearly independent paths through the source code. It is defined as

G is a program's flowgraph or vector of graph

e is the number of edges (arcs) in the flowgraph

n is the number of nodes in the flowgraph

By using the control flow graph developers can determine the independent execution path and tester can assure that all the paths have been tested at least once in the white box testing.

Nodes-> Computational statement or expressions

Edges-> Transfer of control between nodes.

Example ->

So the execution path are 3-

Formula 1->

V(G) = Number of Region + 1

V(G)= (ABFDC)(CDFE) + 1

V(G)= 3

Formula 2->

V(G)= E-N+2

V(G)= 7-6+2

V(G)= 3

Cyclomatic complexity defines the number of linearly independent paths through the source code. It is defined as

**e-n+2**, where e and n are the number of edges and nodes in the control flow graph.**V(G) = e − n + 2**G is a program's flowgraph or vector of graph

e is the number of edges (arcs) in the flowgraph

n is the number of nodes in the flowgraph

**Control Flow Graph**By using the control flow graph developers can determine the independent execution path and tester can assure that all the paths have been tested at least once in the white box testing.

Nodes-> Computational statement or expressions

Edges-> Transfer of control between nodes.

Example ->

**This diagram shows the control flow graph for the above code. Here, e=7, n=6.**

So the execution path are 3-

- A-B-F
- A-C-D-F
- A-C-E-F

**According to the formula->**Formula 1->

V(G) = Number of Region + 1

V(G)= (ABFDC)(CDFE) + 1

V(G)= 3

Formula 2->

V(G)= E-N+2

V(G)= 7-6+2

V(G)= 3

## 0 comments:

## Post a Comment