我怎么知道该开关程序的真正圈复杂度?

时间:2019-12-06 17:46:17

标签: nodes flow edges cyclomatic-complexity

我一直在做一个练习的测试程序,然后出现下一个问题。 人们总是说有两种方法可以求出圈复杂度:

1. V(G) = E - N + 2
2. V (G) = P + 1

E - Number of edges
N - Number of Nodes
P = Number of predicate nodes (node that contains condition)

我为该程序制作了以下流程图。

Flow network of the program carried out

但是,如果我应用公式,每个公式都会给我带来不同的结果:

E = There are 30 edges
N = There are 23 nodes
P = There are 6 predicate nodes(1,6,7,8,9,16)

1. V(G) = E - N + 2 = 30 - 23 + 2 = 9
2. V (G) = P + 1 = 6 + 1 = 7

怎么可能?

0 个答案:

没有答案