In: Computer Science
Referring the image of control flow graph attached
cyclomatic complexity can be calculated in following way:
1)Count the number of regions. As seen in the CFG(Control flow graph) there are 11 regions which I have numbered.
2) Count the no. of predicates + 1. As seen in CFG I have shaded predicate nodes which are total 10 nodes. Hence cyclomatic complexity=10+1=11.
Therefore cyclomatic complexity=11
Essential complexity, ev, is calculated by flowgraph reduction. Flowgraph is reduced by removing decisions that conform to single-entry, single-exit constructs. In above case if(p==q) block has single entry and single exit. Hence can be reduced to single construct.
Therefore Essential complexity=1
Module design complexity is calculated by completely removing decisions and nodes that do not affect the control calls over a module’s immediate subordinates. Above graph is reduced as following:
Therefore Module design Complexity=2
Integration Complexity is given by formula S1 = (Σ iv(Gi )) - n + 1
where n is number of modules. Here we have 5 modules and
respective IVs are shown in figure.
Using formula S1=(2+1+1+1+1)-5+1=2
Therefore Integration Complexity=2