Cyclomatic and Loc Complexity
Cyclomatic and Loc Complexity
•
It helps in determining the software quality.It is an
important indicator of program code’s readability,
maintainability and portability.It helps the
developers and testers to determine independent
path executions.It helps to focus more on the
uncovered paths.It evaluates the risk associated
with the application or program.It provides
assurance to the developers that all the paths have
been tested at least once.
Properties of Cyclomatic Complexity-
• IF A = 354
• THEN IF B > C
• THEN A = B
• ELSE A = C
• END IF
• END IF
• PRINT A
Diagram
• We draw the following control flow graph for
the given code-
•
•
• Using the above control flow graph, the cyclomatic complexity may be calculated as-
•
• Method-01:
•
• Cyclomatic Complexity
• = Total number of closed regions in the control flow graph + 1
• =2+1
• =3
•
• Method-02:
•
• Cyclomatic Complexity
• =E–N+2
• =8–7+2
• =3
•
• Method-03:
•
• Cyclomatic Complexity
• =P+1
• =2+1
• =3