This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Cyclomatic Complexity  RSS feed

 
Ranch Hand
Posts: 186
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am attempting to find the cyclomatic complexity for a method in code. I have numbered the lines to represent nodes, although I'm not sure if it's 100% correct:



Here is a flow graph, again, I would like to get some feedback about whether I am correct or incorrect. Thanks!



if the img html tag does not work, here is my flow graph: https://1drv.ms/u/s!AvALpeZvjVx7geByBUjQVgZEZs2Lag
 
Marshal
Posts: 64496
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou for the effort you put into that question

I looked up cyclomatic complexity on Wikipedia and it gives a formula for calculating it. Which formula did you use? I am presuming your diagram is correct and haven't verified it.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Naziru,

From a psychological view, complexity varies in terms of nodes, as different analyst interprets nodes differently (some consider two sequences as one node while other treat them separately) but the underlying principle remains the same.

Using the P+1 formulae will tell you whether you're right or wrong if you're calculating from a given piece of code. P = Predicate. A predicate is where you have branches in your code. Eg.

From your code, I can see three predicates; Therefore 3P + 1 = 4 Regions and your answer shows only three regions.

You might want to look at it again.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!