English 中文(简体)
Software Testing Dictionary

A

B

C

D

E

F

G

H

I

K

L

M

N

O

P

Q

R

S

T

U

V

W

Useful Resources

Selected Reading

Cyclomatic Complexity
  • 时间:2024-03-21 02:04:17

Cyclomatic Complexity


Previous Page Next Page  

What is Cyclomatic Complexity?

天气复杂性是一种源代码复杂度测量,与一些编码错误相关。 计算方法是开发一部控制流动图,通过一个方案模块衡量依赖线性途径的数量。

降低该方案的体质复杂性,降低修改风险和更容易理解。 代表委员会可采用以下公式:

Cyclomatic complexity = E - N + 2*P 
where,
  E = number of edges in the flow graph.
  N = number of nodes in the flow graph.
  P = number of nodes that have exit points

Example :

IF A = 10 THEN 
 IF B > C THEN 
   A = B
 ELSE
   A = C
 ENDIF
ENDIF
Print A
Print B
Print C

FlowGraph:

Cyclomatic complexity in Test Life Cycle

环形复杂性是利用上述控制流图计算的,该图显示7个点(沙皮)和8个边缘(线),因此,宇宙复杂度为8 - 7 + 2 = 3

Advertisements