代码环复杂度的计算公式
i042416 commented on Feb 17, 2017
來了解一下軟件工程中代碼環(huán)復(fù)雜度的定義。
the cyclomatic complexity of a program is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity M is then defined as:
M = E ? N + 2, where
E = the number of edges of the graph.
N = the number of nodes of the graph.
Take this very simple report for example, it has cyclomatic complexity calculated as 3 by code inspector.
Why calculated as 3? See the directed graph for this simple report below:
[圖片]
要獲取更多Jerry的原創(chuàng)文章,請關(guān)注公眾號"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的代码环复杂度的计算公式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 最值得买的1TB手机?真我GT Neo5
- 下一篇: windows 10 systeminf