There is a subtle difference between cyclometric complexity and full branch coverage.
Cyclometric complexity is a pure mathematical metric. Plainly put - measuring the number of paths that add a new branch to the current paths set.
So in your example - we start with an empty set. false/false
is one path (#1), and then true/false
adds a new branch (the first if
) (#2). Then false/true
adds a new branch (the second if
) (#3).
However the path true/true
does not add a new branch to the set, since all of the points it visits can also be visited by combining path #2 and path #3.
This results remains no matter what is the order that you're adding the paths to the set - always the last (4th) path will not add a new branch that wasn't visited by the previous paths.
Full branch coverage - on the other hand - is more of a software metric. Since we know that in software sometimes testing two branches together can give a different result then just relying on testing the first branch, and separately testing the second branch.
In graph theory cyclometric complexity does not take into account those cross-relations between the branches (just the number of "new" branches), but in software engineering if you want full coverage you need to test all of the possible paths.
Generally - number of minimal tests required <= cyclometric complexity <= number of tests for full branch coverage.