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

hi this is satish can some one help me out by sending the maxium notes on client sesrver ,web server and company architechture project hirearchy and company hirearchy i will happy to recive the answers as early as possible

1724


What do you think the role of test-group manager should be? Relative to senior management?

1671


How can write testcases on a code under development pls give asnwer

1537


how to access a build & wat is its configuration

1765


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.

1613






What kind of input do we need from the end user to begin proper testing?

953


PLS SEND REAL TIMERS, WHAT IS SOA TESTING..IM TRYING 3+ YR.. I HAVE GOOD KNOWLEDGE ON MANUAL TESTING... NOW IM NEW TO LEARN "SOA TESTING" IS BEST OR NOT? BEFORE LEARNING SOA TESTING ANY SKILLS ARE REQUIRED..... AND NOW WHAT IS THE MARKET FOR SOA TESTING... AND IT IS BASED ON PROGRAMMING OR NOT?

2332


Hello, I want to know how to write a regression test plan? Can someone please send me the format/template? Thanks in advance

1635


Hi, I am planing to give ISTQB - Foundation level exam. Can anyone forward the ISTQB materials at laxmi_002@rediffmail.com mail ID.

1466


9.Data – driver automation typically includes?

2915


How we can test Cookies Manually?

1804


wat is meant by frontend and backend testing

5262


Can u give me explanation about section 508 testcase and Testcase for this section. It need a details checklist for the same Manimozhi

2249


user id @ yahoo.com (or) yahoo.co.in (or) gmail.com.... etc

1934


Hi , Please send me the interview questions which were asked in manual testing mainly the test cases asked to write in interview.

1501