What is Cyclomatic Complexity?

后端 未结 15 1367

A term that I see every now and then is \"Cyclomatic Complexity\". Here on SO I saw some Questions about \"how to calculate the CC of Language X\" or \"How do I do Y with th

15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 20:34

    Wikipedia may be your friend on this one: Definition of cyclomatic complexity

    Basically, you have to imagine your program as a control flow graph and then

    The complexity is (...) defined as:

    M = E − N + 2P
    

    where

    • M = cyclomatic complexity,
    • E = the number of edges of the graph
    • N = the number of nodes of the graph
    • P = the number of connected components

    CC is a concept that attempts to capture how complex your program is and how hard it is to test it in a single integer number.

提交回复
热议问题