what is cyclomatic complexity? plz explain with example

Answer Posted / dheemanth kumar

Cyclomatic complexity is a software metric (measurement).
It was developed by Thomas McCabe and is used to measure
the complexity of a program. It directly measures the
number of linearly independent paths through a program's
source code.
M = E − N + 2P
where

M = cyclomatic complexity
E = the number of edges of the graph
N = the number of nodes of the graph
P = the number of connected components.
"M" is alternatively defined to be one larger than the
number of decision points (if/case-statements, while-
statements, etc) in a module (function, procedure, chart
node, etc.), or more generally a system.

Separate subroutines are treated as being independent,
disconnected components of the program's control flow graph.


[edit] Alternative definition
v(G) = e − n + p
G is a program's flowgraph
e is the number of edges (arcs) in the flowgraph
n is the number of nodes in the flowgraph
p is the number of connected components

[edit] Alternative way
There is another simple way to determine the cyclomatic
number. This is done by counting the number of closed loops
in the flow graph, and incrementing the number by one.

i.e.

M = Number of closed loops + 1
where

M = Cyclomatic number.

Is This Answer Correct ?    19 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain accessibility testing and its importance in the present scenario.

665


How to integrate Bugzilla with QTP?

2271


how will we change the server system time?

1789


Manual and automation how do they help in bringing out quality product? Explain?

1468


How to test an Scheduled event? For ex: in an investment banking application, the scheduler will create an equity anbd user has nothing to do but tester has to test if the instrument is created properly or not?

1697






How can a LOG for testcases be maitained which can give information about a TestCase that is it new one or has been occured in previous versions of the software.

1579


Which model is following in your company for developing software?

698


What is white box testing?

740


There are some features to improve the performance of a Product. What are those factors?

1602


1.What is configuration Management? 2. Explain Impact Analysis 3. Explain Peer Review 4. what i kickoff phase of Formal Review. 5. Whatv are the phases of fundamental test process. 6. what is state transition testing. 7. what is LCSAJ 8. Test conditions are derived from where?

1512


What's the relationship between environment reality and test phases?

886


What is defect removable efficiency?

683


Explain the components of a test plan?

673


What are the various techniques in black box testing?

718


Explain the defect life cycle.

620