Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cyclomatic complexity (or conditional complexity) is a software metric (measurement). Its gives the number of indepented paths through strongly connected.

Similar presentations


Presentation on theme: "Cyclomatic complexity (or conditional complexity) is a software metric (measurement). Its gives the number of indepented paths through strongly connected."— Presentation transcript:

1

2 Cyclomatic complexity (or conditional complexity) is a software metric (measurement). Its gives the number of indepented paths through strongly connected directed graphs. It directly measures the number of linearly independent paths through a program's source code.

3 Cyclomatic complexity is computed using the control flow graph of the program which contains node, edges, unconnected part of graph. Cyclometic complexity can b used for following: To find the number of paths to look for basis path testing. To indicate a unit testability, understandability and maintainability. To indicate the effort required to test a unit

4 Complex modules are harder to understand. Such modules are: more prone to errors, hard to test and are harder to modify. Cyclomatic Complexity calculation helps to decide whether the module under test consideration is overly complex or is well written. Hence, during Code-based Testing, testers shall arrive at Cyclomatic Complexity of each programming module, based on the value of it.

5  If value of Cyclomatic Complexity is more than 10, the structure of the module is overly complex.  If value of Cyclomatic Complexity is more than 5 and less than 10, the structure of the module is complex indicating that the logic is difficult to test  If value of Cyclomatic Complexity is less than 5, the structure of the module is simple indicating that the logic is easy to test. 5

6 Paths in Graphs (1)  A graph is strongly connected if for any two nodes x, y there is a path from x to y and vice versa  A path is represented as an n-element vector where n is the number of edges  The i-th position in the vector is the number of occurrences of edge i in the path 6

7 A strongly connected graph. This graph has 10 edges, 8 nodes

8 Linearly Independent Paths  A path p is said to be a linear combination of paths p 1, …, p n if there are integers a 1, …, a n such that p =  a i  p i  A set of paths is linearly independent if no path in the set is a linear combination of any other paths in the set  A basis set of cycles is a maximal linearly independent set of cycles In a graph with e edges and n nodes, the basis has e  n + 1 cycles  Every path is a linear combination of basis cycles 8

9 Arriving at Cyclomatic Complexity

10 Step 2: Count number of nodes in flow graph, n Step 3: Count number of edges in flow graph, e Step 4: Determine Cyclomatic complexity, V(g) = e-n+2 Step 5: Determine a basis set of linearly independent paths. Step 6: Prepare test cases that will force execution of each path in the basis set.

11 Step 1: Flow Graph Representation

12 Step 2: Cyclomatic Complexity Calculation Number of nodes, n= 15 Number of Edges, e= 13 Cyclomatic Complexity, V (g) = e – n + 2 = 15 – 13 + 2 = 4

13 Thank you :


Download ppt "Cyclomatic complexity (or conditional complexity) is a software metric (measurement). Its gives the number of indepented paths through strongly connected."

Similar presentations


Ads by Google