Software Engineering - cyclomatic complexity

AI Thread Summary
The discussion centers on a homework problem involving cyclomatic complexity and flow graphs. A user seeks clarification on their flow graph construction, particularly regarding an if statement within a while loop. Feedback indicates a mistake in the flow diagram, where the conditions for executing process q are incorrectly represented. The user calculates the cyclomatic complexity as 7 but questions the existence of 8 paths in their analysis. The conversation concludes with suggestions to verify the path count against textbook examples for accuracy.
ming2194
Messages
31
Reaction score
0

Homework Statement


[PLAIN]http://img17.imageshack.us/img17/651/cyclomaticcomplexity.png

Homework Equations


Main problem on part (i), am i correct on constructing the flow graph?
The If statement after process x makes me quite confused.

The Attempt at a Solution


[PLAIN]http://img141.imageshack.us/img141/5377/attempt2009ppc3page2.png
[PLAIN]http://img714.imageshack.us/img714/4234/attempt2009ppc3page3.png
 
Last edited by a moderator:
Physics news on Phys.org
The image of your solution is too large: 1654 x 2339 pixels. Please shrink it to about 600 x 800 and repost.
 
ok now. Thanks
 
Much better. Now I can see it without having to scroll up-down and left-right. You have a mistake on the if statement inside the while loop. Process q executes if either or both of the following is true:
1. condition d is true AND condition f is true
2. condition e is true

In your flow diagram you are saying that if d is true and f is false, q executes. That is incorrect.

There's another thing I would change -- I would move the arrow going from "a" to "end if" so that it goes to "end mymodule".
 
[PLAIN]http://img822.imageshack.us/img822/1746/image001zqp.jpg
Is this time correct?

(ii) Cyclomatic Complexity = 7, since there are 7 regions in the whole flow graph.

(iii) 8 paths?
1. n-end if-end mymodule
2. n-m-end if-end mymodule
3. n-m-t-a-end if-end mymodule
4. n-m-t-a-x-d-e-q-k-a-end if-end mymodule
5. n-m-t-a-x-d-e-q-k-a-end if-end mymodule
6. n-m-t-a-x-d-f-q-k-a-end if-end mymodule
7. n-m-t-a-x-d-f-e-q-k-a-end if-end mymodule
8. n-m-t-a-x-d-f-e-k-a-end if-end mymodule

**Why I found there are 8 paths?! Not support to be 7 paths only?!

Hope you can help me to check patiently since I m going to face this type of question in the coming up exam and I don't want to lose any marks...

And for your last statement, what you suggest to me?
 
Last edited by a moderator:
I don't see anything wrong in your flow diagram now. As far as how many paths, and whether there should be 7 or 8, I don't know. The best thing to do is count them, I think. If your book has any examples, take a look at them and see whether you are doing the same thing.

Regarding my comment about moving the arrow from a to end-if so that it points to end-mymodule, I don't think it matters much either way.
 
Back
Top