Professional Documents
Culture Documents
Objective of the Tutorial: To draw a Flow Graph, a DD Graph, calculation of Cyclomatic Complexity
V(G) and find out all independent paths from the DD paths graph, for the case of quadratic equation ax2
+ bx + c = 0 where three coefficients a, b and c roots are calculated. The output may be real roots,
imaginary roots or equal roots or even the equation may not be a quadratic equation.
When we have a flow graph, we can easily draw another graph that is known as decision-to-decision or
(DD) path graph, wherein we lay our main focus on the decision nodes only. The nodes of the flow graph
are combined into a single node it they are in sequence.
Process of constructing the DD Graph leading to computation of Cyclomatic Complexity goes like
this:
# include <stdio.h>
# include <conio.h>
# include <math.h>
(2) {
(4) double D;
(11) if ((a > =0) && (a < = 00) && (b > = 0) && (b < =100) && (c > =0) && (c < =100)) {
(12) boolean = 1;
(13) if (a = = 0) {
(15) }
(16) }
(17) if (boolean = = 1) {
(18) d = b * b – 4 * a * c;
(19) if (d = = 0) {
(20) printf ("roots are equal and are r1= r2 = %f - b/(2 * float)&));
(21) }
(24) printf ("roots are real and are r1=%f and r2=%f; (-b - D)/(2 * a), (-b + D)/(2 * a));
(25) }
(26) else {
(29) }
(30) }
(33) }
(34) else {
(37) getch ( ):
(38) return 0;
(39) }
Since, nodes 1-10 are sequential nodes in the above flow graph, hence they are merged together as a single node – “a”.
Since node –“11” is a decision node, thus we cannot merge it any more.
Likewise we can go on deciding the merging of nodes & arrive at the following DD Path Graph
We get following decision table.
11 b Decision Nodes
12 c Intermediate Node
13 d Decision Node
17 g Decision Node
18 h Intermediate Node
19 i Decision Node
22 k Decision Node
31 o Decision Node
Method – 1: V(G) = e – n + 2 ( Where “e” are edges & “n” are nodes)
V(G) = 24– 19+ 2 = 5 + 2 = 7
Conclusion – 1: Each of these paths consists of at least one new edge. Hence this basis set of paths
is NOT unique.
Conclusion – 2: Test cases should be designed for the independent path execution as identified
above.
Conclusion – 3: We must execute these paths at least once in order to test the program thoroughly.
Please Click here to read many more Articles & Tutorials on White Box Testing