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

can you show me the test cases on registration form

1230


how to write defects in excel sheets when defects occured

1542


What is fuzz testing?

653


What is application programming interface (api)?

656


Can any body tell me in real time how cookies testing is done. And please tell me the steps.And for cookies testing test cases is needed.

1618






what are your achievements in your organization ? Guyz very very urgent , help me

1655


What are parametere require for Performance testing?

1923


1. what exactly is heuristic checklist approach for unit testing ?

2225


What a team leader will test first when s/he will get new module to test?

1549


Hello all, Can someone tell me what kind of questions i can expect from hiring manager along with two team members on final face to face interview for manual testing position.. I am switching from BA to QA as its better on benefits etc.. Thanks in advance

1474


When the GUI Testing will be held on the V model ?

1729


What is the test case?

650


Diffrernce between client server testing and web server testing.

1743


Is there any procedure of web-site development in manual testing. If yes what are factors we should test?

1861


Please send any one latest 3+ years of experience testing tools resumes my mail id is krishnavenimodaliar26@gmail.com

2879