Talk:Cyclomatic complexity

message: The "Alternative Way" section is not helpful, as it uses the undefined term "number of closed loops".  The author might be getting at the reason behind the term "clclomatic", which is that if the (directed) control flow graph is viewed as an undirected graph, the cyclomatic number is the minimum number of edges that must be removed to remove all loops from the undirected graph.  However, this calculation is hardly any easier than counting the number of branches (conditionals).
I recommend removing the "Alternative Way" section or replacing it by describing the connection to the cyclomatic number in undirected graphs.
Greg sullivan 19:52, 23 August 2006 (UTC)
replies: text: Alternative way seems to have been removed but the second example still refers to it. It uses a formula that doesn't have a 2 in it. X10 (talk) 15:13, 21 June 2018 (UTC)
thread_title: Alternative Way is not helpful

message: http://c2.com/cgi/wiki?CyclomaticComplexityMetric
has the definition:
 E = number of edges in the graph.
 N = number of nodes in the graph.
 P = number of nodes that are exit points
      (last instruction, return, exit, etc.)
  
  Then
  
 Cyclomatic complexity = E - N + P
That's a simpler explanation of 'P' than 'connected nodes'.
It really means 'ways in which this module can branch
to out to other modules'.
The article says, "It directly measures the number of linearly independent paths through a program's source code.". Wouldn't it be better to say that it gives an upper bound on the number linearly independent paths? For example, in the first control flow graph given in the margin, there are as few as two or as many as three linearly independent paths.
75.87.186.225 (talk) 17:15, 23 October 2009 (UTC)
thread_title:  Clarifications 

message: That rule of thumb is a bit unbelievable. I have a simple frame of C code with 4 functions: main(), parse_options(), print_version() and print_usage(). There are only two available options: "help" and "version". The file is 89 lines long, but only 67 of them are real lines of code. Cyclomatic number for such a simple file is equal to 8, according to measure done by cccc. So is the file close to be "error-prone"? Is article wrong, rule of thumb is wrong, cccc is wrong or maybe I don't understand something? Could someone explain this, please? LukMak 18:20, 28 March 2006 (UTC)
thread_title:  Rule of thumb 

message: ;Against
:My two cents: merging this article ("cyclomatic complexity") with "essential complexity" doesn't make sense, because cyclomatic complexity is a method of measuring complexity (of a body of code / instructions), and the complexity which this method measures isn't implicitly categorized as either "essential" or "accidental".  That's one of the strengths of cyclomatic complexity measurement, frankly: it's just one objective measurement of complexity, and it doesn't try to assert whether anything can or should be done about the complexity that it measures.  Cyclomatic complexity and essential complexity are effectively in different categories that I would name something like "measures of complexity" and "interpretation / meaning of complexity", respectively. Mlibby 16:20, 17 March 2007 (UTC)
replies: text: Cyclomatic complexity is one measure of the total complexity of a computer program; essential complexity is a kind of complexity found in a problem.  Sometimes people write programs to solve problems, and in that case the essential complexity of the problem often finds its way into the program, but there's always other complexity involved as well.  In short, cyclomatic complexity is very different from essential complexity, and the two are only loosely related. Kragen Sitaker 02:34, 1 April 2007 (UTC)
thread_title:  Discuss: Merge article with "essential complexity" 

message: Is it possible to apply cyclomatic complexity to code written in a functional programming language, or otherwise?  If not, then the article should specify the paradigms to which cyclomatic complexity applies.  If something similar is possible with functional programming language, it would be interesting if the article discussed it.
Mgsloan 04:37, 2 October 2007 (UTC)
thread_title:  Functional vs Imperative Programming 

message: But have a few concerns that I can't really answer myself.  First: the "formal definition" section goes beyond my understanding of this topic by straying into a field of mathematics that I know little about.  But, I can find no sources that discuss the topic in these terms.  A google search for '"cyclomatic complexity" "relative homology"' turns up nothing except wikipedia mirrors.  Is this original research? 
:There appears to be more than one formal definition of cyclomatic complexity: for example see Henderson-Sellers  .  Henderson-Sellers claims that one metric is better suited to module-level testing while the other is more appropriate for system-level, integration testing.  The article should at least mention other definitions.  Here are some more relevant articles:
:*Baker, A.L. and Zweben, S.H. (1980) A comparison of measures of control flow complexity. IEEE Transactions of Software Engineering, 6(6), 506–512.
:*Feghali, I. and Watson, A.H. (1994) Clarification concerning modularization and McCabe's cyclomatic complexity. Communications of the ACM, 37(4), 91–92.  
:*Henderson-Sellers, B. (1992) Modularization and McCabe's cyclomatic complexity. Communications of the ACM, 35(12), 17–19.
:*Shepperd, M. (1988) A critique of cyclomatic complexity as a software metric. Software Engineering Journal, 3, 30–36.
:*Weyuker, E.J. (1988) Evaluating software complexity measures. IEEE Transactions of Software Engineering, 14(9), 1357–1365.
:Hope that helps. pgr94 (talk) 22:34, 24 March 2009 (UTC)
replies: text: Well, the original McCabe proposal for the CC, resided on the definition of Cyclomatic Number in the graph theory. Berge defined it in Graphs and Hypergraphs. But the same number could also be defined in a branch of that theory called topological graph theory and, if so, that definition is exactly the same as reported in the wiki page. Of course the first is simpler and more pratically useful, but this is the subtle relation between them. --Ciosbel (talk) 20:30, 8 January 2010 (UTC)

text: I think that the meaning "prediction ability" is intended as predicting the future program failures (or defects) from its complexity. I've found the slides you mention and only slide 17 matters. I've also found an article by Les Hatton about comparing defects against a wide varierty of well-known static measures (and of course also CC) looking for correlations. The analysis was done on the NAG Fortran library already cited in the slides. As it turned out, he found there were a correletion between CC and the number of executables lines of code; Quoting from the article: "[...] it is extremely likely that there will be a decision about every 3-4 executables lines of code [...]" and he stated even an equation for that. So i think the original author ment that for "CC has the same prediction ability as lines of code".Here there's the article. Ciosbel (talk) 19:21, 8 January 2010 (UTC)
thread_title:  Attempting to improve clarity of the article 

message: The article about Connected component does not deal with directed graphs very well. If it is applicable to interpret the flow graph as undirected, there can almost never be a P > 1 (a function use to have only one entry point, and all nodes are reachable from that). Can anyone give an example where P > 1? -- 130.236.56.173 (talk) 11:00, 12 January 2010 (UTC)
replies: text: Yes, one should consider the flow graph as undirected for purposes of computing the cyclomatic number. A case with P>1 could be if one considers a code library rather than a program, as each exported function then has its own entry point. Multithreaded programs is perhaps another (although, now that I think about it, that is perhaps more properly dealt with by forming a product of the flow graphs for the different threads). 130.239.119.132 (talk) 13:02, 11 February 2011 (UTC)
thread_title:  Example where P>1 

message: The fundamental group of a 1-dimensional CW complex should be the free group on n generators, not Z^n, unless I'm very much mistaken. Additionally, are we including the loop from end to start when computing the fundamental group? In the example under Implications For Software Testing, it gives the complexity as 3, but using the graph next to it (with end->start connection) would give the free group on 3 generators as homotopy- and it says earlier that the value is then one more than that. I think it is more intuitive to use the looped graph and say that if pi-1(X) is the free group on n generators, then n is the cyclomatic complexity; either way, what we're taking the fundamental group of should be made more clear, I believe.
Cyrapas (talk) 22:10, 7 May 2013 (UTC)
thread_title:  Homotopy 

message: This statement:
A better name for popular usage would be conditional complexity, as "it has been found to be more convenient to count conditions instead of predicates when calculating complexity".[6]
is confusing. Cyclomatic complexity can be easily calculated by counting number of branches, not conditions or predicates. The formula is then:
CC = 1 + sum_{nodes n: n has outdegree > 1} (outdegree(n)-1)
In fact, if you don't use switch-case-type instrucions (you can always change it to a sequence of IF statements), the cyclomatic complexity is: one plus number of places where the decision (that is: PREDICATE!!!) is made. Decision is a predicate, not condition! Condition is a part of a predicate and has nothing to do with cyclomatic complexity. In fact, it is more convenient to use predicates, not conditions when calculating CC (you can argue the quoted McCabe's statement!)
Someone should change this fragment, as it's very confusing.  — Preceding unsigned comment added by 89.72.75.243 (talk) 22:05, 25 November 2013 (UTC)
thread_title:  Etymology/Naming section contains confusing statements 

message: Re this line:
The set of all even subgraphs of a graph is closed under symmetric difference
The symmetric difference of subgraphs of a graph is not discussed in the wikipedia page for symmetric difference that is linked.  — Preceding unsigned comment added by Scott Allen Brown (talk • contribs) 00:09, 13 December 2013 (UTC)
thread_title:  Symmetric Difference wikipedia entry linked is for sets, not graphs 

message: The example shown has cyclomatic complexity 3, not 4 (9 - 7 + 1 for strongly connected graph)  — Preceding unsigned comment added by 169.145.89.205 (talk) 00:17, 27 June 2014 (UTC)
thread_title:  Wrong CC number in example in "Implications for software testing" 

message: I thought I found a book that calls it this way  but it turns out they are citing this Wikipedia page!!! 188.27.81.64 (talk) 22:03, 16 July 2014 (UTC)
thread_title:  "Conditional complexity" OR?? 

message: This article uses the phrase "linearly independent paths" several times without defining it.  What does it mean?  --Doradus (talk) 14:56, 11 August 2019 (UTC)
thread_title:  What are linearly independent paths?