• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Calculation of Cyclomatic Complexity & understanding of its Properties
McCabe's Cyclomatic metric, V(G) of a graph “G” with “n” vertices and “e” edges is given by the followingformulaV(G) = e – n + 2Let us take an example of a program; wherein we associate it with a directed graph that has unique entry andexit nodes. Each node in the graph, G, corresponds to a block of statements in the program where flow issequential and the arcs correspond to branches taken in the program. This graph is known as a “Flow Graph”.
The Cyclomatic Complexity, V(G) provides us two things
1) To find the number of independent paths through the program.2) To provide an upper bound for the number of test cases that must be executed in order to test the programthoroughly. The complexity measure is defined in terms of independent paths. It is defined as any paththrough the program that introduces at least one new set of processing statements or a new condition.The following steps are usually followed
Step – 1:
Construction of flow graph from the source code or flow charts.
Step – 2:
Identification of independent paths.
Step – 3:
Computation of Cyclomatic Complexity.
Step – 4:
Test cases are designed.Using the flow graph, an independent path can be defined as a path in the flow graph that has at least oneedge that has not been traversed before in other paths. A set of independent paths that cover all the edges isa basic set. Once the basis set is formed, test cases should be written to execute all the paths in the basis set.
Properties of Cyclomatic Complexity
The following are the properties of Cyclomatic Complexity represented as V(G)1) V(G) >= 1.2) V(G) is the maximum number of independent paths in graph, G.3) Inserting and deleting functional statements to G does not affect V(G).4) G has only one path if and only if V(G) = 1. Consider the following example
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...