0

consider this control flow graph. we need to find total independents liner path. when we use "V(g) = e-n+2 = 7-6+2 = 3"

but if i count manually i got 4 independents liner path. paths are:

"0=>1=>3=>5", "0 => 1 => 3 => 4 => 5", "0 => 2 =>3=> 5", "0=> 2 => 3 => 4 => 5"

why this both value are different?

[Control flow graph here][1]

[1]: https://i.stack.imgur.com/vRBmD.png

1 Answers1

0

For calculating McCabe complexity, you need to find edges and nodes. The first formula will be:

v(F) = edge - node + 2

The second formula is:

v(F) = # of decision nodes + 2

Note that # of decision nodes also named as predicate nodes.

Now there are 6 nodes (circles) and 7 edges (arrows) in your graph.

Therefore McCabe complexity will be = v(F) = 7 - 6 + 2 = 3.

The second way to solve is:

There are two predicate nodes (decision nodes) 0 and 3 so v(F) = 2 + 1 = 3.

Ahmet
  • 7,527
  • 3
  • 23
  • 47