Cyclomatic complexity

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. It is computed using a graph that describes the control flow of the program. The nodes of the graph correspond to the commands of a program. A directed edge connects two nodes if the second command might be executed immediately after the first command.


Definition


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.


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


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 that number by one.

i.e.

M = Number of closed loops + 1

where

M = Cyclomatic number.


Implications for Software Testing:

  • M is a lower bound for the number of possible paths through the control flow graph.
  • M is an upper bound for the number of test cases that are necessary to achieve a complete branch coverage.

For example, consider a program that consists of two sequential if-then-else statements.

if (c1) {
f1();
} else {
f2();
}

if (c2) {
f3();
} else {
f4();
}

  • To achieve a complete branch coverage, two test cases are sufficient here.
  • For a complete path coverage, four test cases are necessary.
  • The cyclomatic number M is three, falling in the range between these two values, as it does for any program.

Cyclomatic complexity can be applied in several areas
, including:
  • Code development risk analysis: While code is under development, it can be measured for complexity to assess inherent risk or risk buildup.
  • Change risk analysis in maintenance: Code complexity tends to increase as it is maintained over time. By measuring the complexity before and after a proposed change, this buildup can be monitored and used to help decide how to minimize the risk of the change.
  • Test Planning: Mathematical analysis has shown that cyclomatic complexity gives the exact number of tests needed to test every decision point in a program for each outcome. Thus, the analysis can be used for test planning. An excessively complex module will require a prohibitive number of test steps; that number can be reduced to a practical size by breaking the module into smaller, less-complex sub-modules.
  • Re-engineering: Cyclomatic complexity analysis provides knowledge of the structure of the operational code of a system. The risk involved in reengineering a piece of code is related to its complexity. Therefore, cost and risk analysis can benefit from proper application of such an analysis.

Comments

QPT said…
Hi,

First of all Thanks very much for your useful post.
I would like to introduce another good blog which is having free software testing ebooks and technical content, Have a look.
http://qualitypoint.blogspot.com/2009/12/released-two-ebooks-for-learning.html
rajesh said…
Thanks for info.

rajesh
http://SoftwareTestingNet.com
Anonymous said…
Genial post and this mail helped me alot in my college assignement. Say thank you you for your information.
Anonymous said…
Hello. And Bye.
Anonymous said…
hi everyone. I'm actually into shoes and I was digging for that exact model. The prices seeking the velcros are around 240 dollars on every page. But finally I base this location selling them for half price. I in reality want these [url=http://www.shoesempire.com]gucci sneakers[/url]. I will probably order those. what do you think?
Anonymous said…
hi bros. I'm honestly into shoes and I have been searching for that particular make. The prices seeking the boots were around 350 dollars on every site. But completely I set this locate selling them as a remedy for half price. I really like these [url=http://www.shoesempire.com]gucci sneakers[/url]. I will probably purchase those. what can you tell me about these?
Anonymous said…
hi bros. I'm honestly into shoes and I was searching for the sake of that exact brand. The prices for the velcros were approximately 200 dollars on every page. But finally I set this site selling them someone is concerned half price. I really want these [url=http://www.shoesempire.com]gucci sneakers[/url]. I will absolutely order them. what do you think?
Anonymous said…
[url=http://buynps.org]Buy Neopoints[/url] online at a cheap price at BuyNPs.org
Anonymous said…
Hi guys,

Would you like to watch harry potter and the deathly hallows? It is not released yet but you can watch it online now already!

Click here to [url=http://watchharrypotterandthedeathlyhallowsonline.org/]watch harry potter and the deathly hallows online[/url]


The Harry potter movie is based on the 7th Harry potter novels which are written by the amazing author J.K.Rowling, totally there are eight series in Harry potter saga. Actually these movies are about magic. People can find the sweet holly wood actors like Rupert Grint, Emma Watson and Watch harry potter and the deathly hallows online free and Daniel Radcliff in these movies. The movie edition of the final book that is Harry potter and the deathly hallows is presently in post production after the last stage of main movie which was done on 12th June 2010. The movie will be released on November 5th 2010. Finally, the last novel was divided into 2 series, that is Harry potter and the deathly hallows part I and Harry potter and the deathly hallows part II.
Anonymous said…
Thanks for sharing this link, but unfortunately it seems to be down... Does anybody have a mirror or another source? Please answer to my post if you do!

I would appreciate if a staff member here at www.blogger.com could post it.

Thanks,
Daniel
Anonymous said…
Bonjour à tous,

Voulez-vous gagner des prix facilement ?

Le site Bidou.ca est un un site web interessant qui vous permet de remporter de super cadeaux sans investir a la folie!

Venez participer sur: [url=http://bidoubidou.ca/]bidou.ca[/url]
Anonymous said…
I've always liked things like sand clocks, lava lamps, and the like to kind of rightful spend time staring at it as a cut of catharsis. In a opportunity, it helps me with meditation, to reduce stress and strain and scarcely assume fro nothing. That's why since I was a kid, in place of of dolls and cars I've in any case cool more of such pieces like sand clocks, lava lamps, dulcet boxes etc. So I was most delighted when I found the[url=http://www.dealtoworld.com/goods-1260-2-Laser++LED+Light+Show+Laser+Top+Gyroscope+with+Music+Effects.html] 2-Laser + LED Spry Show Laser Ace Gyroscope with Music Effects[/url] from DealtoWorld.com under the Toys section. It's like a melodic box, a spinning exceed, and a berate verify all rolled into one. Which is prodigious amusement! The gyroscope will whirl representing about a minute. The laser light manifest with accompanying music makes this gyroscope a rather unique fiddle with that my friends get also been most amused with.

My dogs are also nice-looking outr?about the laser gyroscope I got from DealtoWorld.com. They each attend the gyroscope as it spins, although at earliest they kept barking at the laser diverting dismiss accompany, and also because it produces music. But after they got worn it, they've stopped barking but virtuous maintain following the gyroscope whenever I start spinning it. Kids are also attractive amused next to it. On occasion it's moral to have fun toys throughout the ancestry so that you can desert the toy on while the kids are being amused or playing with it while you open to fit out food or fall heir to changed. The gyroscope is one such play with with this purpose.

The gyroscope I bought from DealtoWorld.com has a dragon as a design on it, and produces a light show with red, dispirited, and unripened colours. Nick a look at the pictures I've uploaded of the gyroscope with laser incandescence show. The music produced from the gyroscope is not that enormous but good adequacy to accommodate any redone guest to the house. The gyroscope is red and jet-black, making it look particular cold, and slightly arrogant with that dragon imprint.

The music luminescence show gyroscope runs on 6 LR44 batteries, which are replaceable anyway. I've also acclimatized this gyroscope to surprise my girlfriend during our anniversary celebration. I did the cheesy terror of decorating the hotel room with roses and when I led her in, I started up the gyroscope as affectionately so that the laser torchlight expose produces a fresh effect. I also had some battery operated candles so all the light effects created a sort of mawkish atmosphere. She loved it, not later than the going, to my relief. I also bought the candles from DealtoWorld.com. These days it seems to be my non-performance shopping site for all gifts and ideas for romantic occasions.

Since Christmas is coming, this laser go down make clear gyroscope can dialect mayhap be a momentous Christmas gift in behalf of the toddler or in spite of the mollycoddle! Alternatively, the gyroscope can simply be a kindly totalling to the usual Christmas decorations. I can imagine placing it near the Christmas tree and perhaps spinning it when guests succeed in the house. Looks like [url=http://www.dealtoworld.com]DealtoWorld.com[/url] is getting my duty anyway again!
Anonymous said…
very passable enquiry

[url=http://swixml.org/forum/index.php?action=profile;u=4262;sa=summary]clean grout[/url]
Your blog is outrageous! I mean, Ive never been so entertained by anything in my life! Your vids are perfect for this. I mean, how did you manage to find something that matches your style of writing so well? Im really happy I started reading this today. Youve got a follower in me for sure!
Anonymous said…
Hello. Facebook takes a [url=http://www.casinobonus.gd]slots[/url] stake on 888 casino deal: Facebook is expanding its efforts to present real-money gaming to millions of British users after announcing a carry out with the online gambling steadfast 888 Holdings.And Bye.
Anonymous said…
swedish free dating site http://loveepicentre.com/articles.php go fish dating service
Anonymous said…
simply dropping by to say hi
Anonymous said…
instant payday loans online http://www.legitpaydayloansonline3.com/ Fundpopog [url=http://legitpaydayloansonline1.com/]Payday loans online[/url] Stype Payday Loans Online cheap payday loans online Most people with having job can can improve such no credit affect business cash advances arrives into the planning.Here are a few other reasons people credits, due customer feedback compared with other types of loans?
Anonymous said…
payday loans online http://www.legitpaydayloansonline1.com/ Fundpopog [url=http://www.legitpaydayloansonline2.com/]Payday loans online[/url] Stype Payday Loans Online Payday Loans Online The main concern of the lender is about the for it interest is it higher in comparison of other loans.Consider borrowing money from friends, family members, anywhere from $100 to $1,000 or more!
Anonymous said…
Payday Loans Online http://www.legitpaydayloansonline3.com/ Fundpopog [url=http://www.legitpaydayloansonline3.com/]Payday loans online[/url] Stype payday loans online payday loans online The credit score of a person is very income is still a few days away, can be due to several reasons.For the credit seekers, they may not get the have a it by paying some scant fees to the lender.
Anonymous said…
ebook exe how to open http://audiobookscollection.co.uk/fr/Communicating-in-Business-Student/p25049/ ebook sales numbers [url=http://audiobookscollection.co.uk/fr/Discontinuous-Systems-Lyapunov-Analysis-and-Robust-Synthesis-under-Uncertainty-Conditions/p228382/]ebook saving charlie[/url] free ebook the story of o
Anonymous said…
scary stories ebook http://audiobooksworld.co.uk/de/Tide-of-Terror/p29202/ annie on my mind ebook [url=http://audiobooksworld.co.uk/fr/Stars-Over-Stars/p205910/]michele novotni ebook[/url] trinity's child free ebook
Anonymous said…
r4 sdhc ebook format http://audiobooksworld.co.uk/J-Glenn-Brookshear/m54020/ douay rhimes bible ebook [url=http://audiobooksworld.co.uk/fr/Management-Quality-and-Economics-in-Building/p220124/]dark river ebook[/url] sony ereader ebook programming software
Anonymous said…
I am really enjoying the theme/design of your weblog. Do you ever run into any internet browser compatibility problems?

A couple of my blog readers have complained about my website not working correctly
in Explorer but looks great in Firefox. Do you have any recommendations to help fix this issue?


Here is my blog post justin bieber supra shoes
Also see my web site :: justin bieber supra shoes
Anonymous said…
[url=http://onlinemedistore.com/products/lukol.htm][img]http://onlinemedistore.com/11.jpg[/img][/url]
generic viagra online pharmacy http://onlinemedistore.com/products/trental.htm retail pharmacy supplies [url=http://onlinemedistore.com/catalogue/a.htm]xopenex hfa pharmacy[/url]
target coupons for pharmacy http://onlinemedistore.com/products/hard-on-oral-jelly.htm wellness pharmacy [url=http://onlinemedistore.com/products/combivent.htm]combivent[/url]
pharmacy free ce credits http://onlinemedistore.com/categories/cardiovascular.htm how to stop obnoxious pharmacy emails [url=http://onlinemedistore.com/products/rogaine-2-.htm]canada pharmacy xanax[/url]
wal mart pharmacy honolulu hawaii http://onlinemedistore.com/products/torsemide.htm pharmacy wheelchair marysville [url=http://onlinemedistore.com/products/deltasone.htm]deltasone[/url]
Anonymous said…
Yesterday, while I was at work, my sister stole my apple ipad and tested to see if it
can survive a thirty foot drop, just so she can
be a youtube sensation. My iPad is now broken and she has 83 views.
I know this is completely off topic but I had to share it with someone!



My website; レイバンメガネ
Anonymous said…
Hi, I do think this is a great website. I stumbledupon it ;) I'm going to return once again since I saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to help other people.

Here is my site ... オークリー サングラス
Anonymous said…
Hi I am so thrilled I found your website, I really found you by
mistake, while I was researching on Google for something else, Nonetheless I am here now and would just like to say thank you for a
remarkable post and a all round interesting blog (I also love the theme/design), I don’t
have time to look over it all at the minute but I have bookmarked it and also added your RSS feeds,
so when I have time I will be back to read much more, Please do keep up the superb
b.

Here is my blog: オークリーメガネ
Anonymous said…
Greetings! Very useful advice within this post!
It is the little changes that make the largest changes.

Thanks a lot for sharing!

Here is my webpage: レイバン 通販
Anonymous said…
I like [url=http://www.nikeshop.ca/]Nike[/url] and http://www.nikeshop.ca/9rvgalbk
Anonymous said…
Excellent write-up. I certainly appreciate this site.
Keep writing!

My web page 激安レイバン
Anonymous said…
Fabulous, what a webpage it is! This website gives valuable data to us, keep it up.


Feel free to visit my web page - オークリー アウトレット
Anonymous said…
If you desire to increase your knowledge only keep visiting this site and be updated with the latest news update posted here.


Here is my web site ... レイバンサングラス
Anonymous said…
For most up-to-date information you have to visit world wide web and on world-wide-web I found this
website as a finest website for hottest updates.


Review my web blog: http://s2.mywebdesign.us/birt/blog/view/22989/oakley-sunglasses-wholesale
Anonymous said…
But it takes to Have some disturbance for his final season of" subliminal" material going away on: We are now fashion workweek, which is simple on Tradesy. Even though she's popular with fashion design, Sweden's H&M, looking so beaming and Pare about the star sign' outfit. Even so, this Treat was that of the macrocosm's moment-largest consumer of mode. www.kasper-suits.net [url=http://kasper-suits.net/]kasper womens suits[/url] [url=www.kasper-suits.net]kasper suits[/url] This is fashion Go forth for 10 seconds to supernumerary for a vote box. kasper suits for women kasper pant suits kasper suits petite Hey fashion design LoversWe in the magazine publisher platform. Add major cutouts, and here's our interlingual rendition of the Tazreen fashion design brings the outcome such as" incrostazione" the make.
Anonymous said…
。ロリークリーフはヤン
キーのための明確な
裏庭を示すハード石
ダイヤルを介
して2つのいくつか
の時計の見事なセ
ットを示し西部。あなたが真剣に、非常に活気の
ある色素を持っているハロウィー
ンの衣装を含めた場合、徹底
的に、手間が存在
するだけでどこ、解決策はいくつかの事実のように
ロープロファイルは、実際
schokohrrutigeを着なければなければな
らない、あなたが実際に表示させるための最善の方法は、あります
パンツや多分ブラウス


my weblog :: coach バッグ
Anonymous said…
弊社のミュウミ
ュウオンライン
ストアではあな
たの参照のための靴のすべての
種類があります

Check out my webpage: ミュウミュウ バッグ
Anonymous said…
あなたが卸売業者であればそ
れも大したことをオン
ラインで取得するための良い方法です

Look at my page - ミュウミュウ 激安
Anonymous said…
Do you mind if I quote a couple of your posts as long as
I provide credit and sources back to your website? My blog is in the exact same area of interest
as yours and my visitors would definitely benefit from a lot of the information you provide here.
Please let me know if this alright with you. Appreciate it!


Here is my homepage: Replica Rolex
Anonymous said…
I every time used to study piece of writing in news papers but now as I am a user of internet therefore
from now I am using net for content, thanks to
web.

Also visit my web blog; cheap nike air max 90
Anonymous said…
I don't even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you're going to a famous
blogger if you are not already ;) Cheers!



my webpage ... モンスタービート
Anonymous said…
I believe that is among the so much important info for me.
And i am satisfied reading your article. But should statement on few normal things,
The web site style is ideal, the articles is in point of fact
nice : D. Excellent job, cheers

Here is my website クロエバッグ新作
Anonymous said…
One is inclusions (present within the very item), blemishes (external).
All the famous company is truly a really hit this required Cannes by way involved with tornado.
Focus on in want to exist when the change is complete.
The growth from this new fashion market is indeed being described
by many of those in the already know just as explosive.

http://aquamira.com/author/MarieV86
Anonymous said…
Have you ever thought about writing an e-book or guest authoring on other
websites? I have a blog based on the same ideas you discuss and would love to have you share some
stories/information. I know my readers would appreciate your work.
If you are even remotely interested, feel free to shoot me
an e-mail.

My website - cheap nike air max shoes
Anonymous said…
I am sure this piece of writing has touched all the internet viewers, its really really fastidious piece of writing on building up new
weblog.

Also visit my web site: cheap nike air max 2009
Anonymous said…
If some one needs expert view on the topic of blogging then i propose him/her
to visit this webpage, Keep up the good work.

Here is my blog post :: cheap nike air max 2009
Anonymous said…
Hi there to every one, for the reason that I am really
keen of reading this web site's post to be updated on a regular basis. It carries good stuff.

my homepage ... nike air max on sale
Anonymous said…
Keep this going please, great job!

Stop by my weblog ... cheap nike air max bw
Anonymous said…
These are actually impressive ideas in on the topic of blogging.
You have touched some fastidious factors here.
Any way keep up wrinting.

Here is my homepage nike air max on sale
Anonymous said…
meilleure caractristique signifiant magasinage durante li
good. You can have 3 or even a couple handbags replica at the price of distinct Louis Vuitton!
Should clients not realize where you should shopping mall on the web, only use their own
search results. Think out among the box and determine unique corporate products.
http://www.socialjob.kr/groups/celine-bags-slang-words-and-phrases-came-across-in-traditional/

my website; custom bags
Anonymous said…
Many nothing an example tint merge manner perhaps even accomplish that has
a major section. Substantial chic, and quote products of good quality at cheaper expenditures.

my own unfavorable, i will stay with youtube
purely eat. To deal with deluxe vehicle travelling
will be practical for additional details about .

http://wiki.dashengjiao.org/index.php?title=%E4%BD%BF%E7%94%A8%E8%80%85%E8%A8%8E%E8%AB%96:CelestaJ2

Here is my web site - promotional sports and duffel bags
Anonymous said…
Realistically it happens to be in several benefits.
Inner compartment space, can accommodate a variety concerning out compact things
important. A wonderful additional exclusive offer provided from the maker is a particular smart purse fishing hook.
The are wedged in name brand nicely as unbranded clothes.
http://www.fullfiles.za.pl/profile.php?mode=viewprofile&u=2455
Anonymous said…
Surplus a number of us could check this out problem being in the center of your respective difficulty.
As yet for some reason, horrid trends continue during.
Include stress-relief corporate gifts in your primary list.

Makowsky purse should appear blessed to tumble hanging from your partner shoulders.
http://dogday.com.tw/forum/profile.php?mode=viewprofile&u=6695

Look into my web blog - replica bags
Anonymous said…
Those pieces happen to be commonly utilised through long Dutch winter months.
Makowsky handbag will be compelled to feel blessed to acquire it hanging from your wife shoulders.
The bagsDiscount cheap tutor is a high-quality choice
for player sacks private teacher lovers. Very low
cost Coach Bags Correct Father christmas he called 'Mr. http://www.bijuter.msk.ru/profile/doylemauld
Anonymous said…
Link exchange is nothing else except it is just placing the other person's weblog link on your page at suitable place and other person will also do similar for you.

Also visit my page - nike air max on sale
Anonymous said…
Hi, i read your blog from time to time and i own a similar
one and i was just curious if you get a lot of spam feedback?
If so how do you reduce it, any plugin or anything you can suggest?
I get so much lately it's driving me mad so any assistance is very much appreciated.

my weblog: www.schumannsflyfishkitco.com
Anonymous said…
air force dating air force one http://loveepicentre.com/map/ foreign women internet dating
who is bryan adams dating [url=http://loveepicentre.com/]dating profile writing services[/url] std match dating
dating your ex spouse ex spouse [url=http://loveepicentre.com]paris hilton dating nascar casey[/url] free dating site usa [url=http://loveepicentre.com/user/judger/]judger[/url] gay black dating
Anonymous said…
bi lezbian dating uk http://loveepicentre.com/taketour/ vegetarian dating sites
male single dating cloudbuster [url=http://loveepicentre.com]dating violence and college campuses[/url] asian women dating white
gary geeman dating london german [url=http://loveepicentre.com/map/]online jewish dating services[/url] free local christan singles dating sites [url=http://loveepicentre.com/user/petrovich/]petrovich[/url] free auult dating
Drishti said…
The Quality Assurance (QA) role is the role responsible for guaranteeing a level of quality for the end client, and to help the software development team to identify problems early in the process. It is not surprising that people in this role are often known as "testers". Of course, the role is more than just testing.

https://maveric-systems.com/services/software-quality-assurance-testing-services

Unknown said…
Keep this going please, great job! Try Also...
UC Browser Mod Apk V12.12.5.1189 [Ad Free]...
https://www.modsmama.com/uc-browser-mod-apk/
Anonymous said…

Coin master is one of the famous and grossing games right now. you can spin the wheel and believe in fortune to get a lot of Spins. But you end up getting small amounts of spins. For those who are searching for Coin Master unlimited spins, this article is very useful to them. We are providing the hourly updated links of the coin master spins. So you don't need to complete annoying surveys to get unlimited spins. To get the unlimited spins you have to go the links below.coin master free spins
hammad said…
Making your journey more comfortable this kayak features; protective thigh pads, adjustable foot braces, and paddle holder.

Best Sit On Top Kayak

You guys will be greatful to know that our institution is conducting online CS executive classes and a free CSEET classes only for you guys. If anyone is interested then feel free to contact us or visit our website for more details https://uniqueacademyforcommerce.com/
Elena James said…
If You Own A Forex Account, IC Market Is A Tool That You Need To Add To Your Trading Portfolio.
SwarnApp said…
Thanks for sharing this article. Really helpful for me.
Girvi Software
Girvi Software

Popular posts from this blog

Appium Configuration with Visual studio for selenium C# development