103

ISBN : 978-81-963532-2-3 (E-Book) V(G)= E– N + 2 where N is the number of nodes of the control flow graph and E is the number of edges in thecontrolflowgraph. FortheCFGofexampleshowninfig.20.3,E=7andN=6.Therefore,thecyclomaticcomplexity= 76+2=3. Method2: An alternative way of computing the cyclomatic complexity of a program from an inspectionofitscontrol flowgraph isasfollows: V(G)=Total numberof boundedareas+1 In the program’s control flow graph G, any region enclosed by nodes and edges can be calledasaboundedarea.Thisisan easywayto determinetheMcCabe’scyclomaticcomplexity. But, what if the graph G is not planar, i.e. however you draw the graph, two or more edgesintersect? Actually, it can be shown that structured programs always yield planar graphs. But,presenceofGOTO’scaneasilyaddintersectingedges.Therefore,fornonstructuredprograms,thiswayofcomputingtheMcCabe’scyclomaticcomplexitycannotbe used. Thenumberofboundedareasincreaseswiththenumberofdecisionpathsandloops.Therefore, the McCabe’s metric provides a quantitative measure of testing difficulty and theultimate reliability. Forthe CFG example shown in fig. 20.3, from a visual examination ofthe CFG the number of bounded areas is 2. Therefore the cyclomatic complexity, computingwith this method is also 2+1 = 3. This method provides a very easy way of computing thecyclomatic complexity of CFGs, just from a visual examination of the CFG. On the otherhand, the other method of computing CFGs is more amenable to automation, i.e. it can beeasily coded into a program which can be used to determine the cyclomatic complexities ofarbitraryCFGs. Method3: The cyclomatic complexity of a program can also be easily computed by computing thenumber of decision statements of the program. If N is the number of decision statement of aprogram,thenthe McCabe’smetricisequalto N+1. DataFlow-BasedTesting Data flow-based testing method selects test paths of a program according to the locations of thedefinitionsand usesofdifferent variablesina program. ForastatementnumberedS,let DEF(S)={X/statementScontainsadefinitionofX},andUSE 98 Software Engineering Keerthana P, Manasa KN, Ganga D Bengal

104 Publizr Home


You need flash player to view this online publication