2

Assume the flow graph of a function is below (sorry I have forgotten the code of the function):enter image description here

And when I try to calculate the cyclomatic complexity:

When I use the edge and node to calculate it, V(G)= 9 - 8 + 2 = 3; when I use the branch node to calculate it, V(G) = 3 + 1 = 4. However, when I try to find the independent paths, I think I can find 4 paths:

Path 1: 1 -> 2 -> 6 -> 7
Path 2: 1 -> 2 -> 6 -> 8
Path 3: 1 -> 2 -> 3 -> 5 -> 2 -> ...
Path 4: 1 -> 2 -> 3 -> 4 -> 5 -> 2 -> ...

And I wonder which one is correct and what is my mistake? Thanks a lot.

asked Jan 4, 2020 at 13:34
2
  • The simplified formulas don't work because you have multiple exit points (states 7 and 8). There are more complete formulas, or you can introduce an exit state E plus the edges 7→E, 8→E. Commented Jan 4, 2020 at 15:20
  • @amon I think it should be 7->E, 8->E Commented Jan 4, 2020 at 16:13

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.