Heilbronn triangle problem: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
 
en>Wavelength
inserting 1 hyphen: —> "higher-dimensional"—User talk:Wavelength#Hyphenation [to Archive 6]
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''Cyclomatic complexity''' (or '''conditional complexity''') is a [[software metric]] (measurement). It was developed by [[Thomas J. McCabe, Sr.]] in 1976 and is used to indicate the complexity of a program. It is a quantitative measure of logical strength of the program. It directly measures the number of linearly independent paths through a program's [[source code]]. The concept, although not the method, is somewhat similar to that of general text complexity measured by the [[Flesch-Kincaid Readability Test]].
BIG APPLE - Jay Victorino was standing exterior his mother's condominium when he was grabbed by police, and he says if she hadn't come downstairs to establish him he would've been arrested on a trespassing charge.<br><br>Mental property legislation impacts many areas of our lives, instantly and not directly. Understanding mental property laws can subsequently assist us to grasp the basic processes concerned in coping with intellectual property in its many manifestations. This course is beneficial for individuals who work in numerous business and industrial settings. It would also be appropriate for those with an interest within the artistic industries. Many Singaporeans have been investing in property throughout the causeway in recent years, attracted by comparatively low prices. Nevertheless, those that have to exit their investments shortly are likely to face vital challenges when trying to sell their property – and could ultimately be stuck with a property they cannot promote.<br><br>Mr. Pua was previously the Chief Government Officer of DLF Worldwide Holdings Pte. Ltd., the international enterprise arm of DLF Limited, India's largest real property company. He was also Chief Government Officer of various CapitaLand Group of corporations, together with CapitaLand Retail Limited (now referred to as CapitaMalls Asia Restricted), CapitaLand Monetary Restricted and CapitaMall Belief Management Restricted. He was a Director on the Board of CapitaRetail China Belief Administration Restricted and The HYPERLINK Management Restricted.<br><br>The Holland district (district 10) is one of the three most desired districts [http://www.tuttaunaltramusica.eu/index.php?do=/profile-58098/info/ best condo in singapore] Singapore (the others being districts 8 and 9). This is not solely as a result of its nice location and proximity to town, its personal residential estates and a bunch of center-class conveniences but in addition due to its pleasant environment. Singapore ought to remain a haven for capital when markets are as unstable and opaque as they are," said stated Tim Gibson, co-head for Henderson Horizon World Property Equities Fund & supervisor of the Henderson Horizon Asia Pacific Property Equities Fund. D19) Hougang / Punggol / Sengkang  Apartment  Common Room with Aircon D22) Boon Lay / Jurong / Tuas  Condominium  Common Room with Aircon An EC with Iconic Skypark! Put up your Property Model New Condos Rental Revenue<br><br>The acquisition seems well timed. San Jose is witnessing a rise in investor urge for food for commercial tasks on the back of a increase within the tech sector. Developers like San Franciso-primarily based Simeon Residential Properties, Cupertino-primarily based KT Properties and Essen Property Belief are respiration new life into the realm that has so long been a laggard in Silicon Valley. Given its cut price worth, Vietnam City seems properly poised to faucet into the market's new buoyancy.<br><br>Whenever you sell Property, your lawyer's primary duty is to make sure that oncompletion, you might be ready to ship the title to the property free from your mortgageand CPF charge. This requires your lawyer to liaise with your bank's and CPF Board'slawyer for fee, out of the sale proceeds, the outstanding mortgage amount and refundof your CPF funds enough to discharge the financial institution's mortgage and CPF charge. HDB Flats You are advised to contact the HDB instantly in respect of the sale and/or purchaseof HDB flats. The HDB has devised their own type of Settlement/Contract for the purchaseof HDB flats. When doing all of your sums, you ought to be conscious that as a international investor, the rent you obtain from your property can be topic to withholding tax.
 
Cyclomatic complexity is computed using the [[control flow graph]] of the program: the nodes of the [[Graph (mathematics)|graph]] correspond to indivisible groups of commands of a program, and a [[Directed graph|directed]] edge connects two nodes if the second command might be executed immediately after the first command. Cyclomatic complexity may also be applied to individual [[function (computer science)|functions]], [[modular programming|modules]], [[method (computer science)|methods]] or [[class (computer science)|classes]] within a program.
 
One [[software testing|testing]] strategy, called [[Basis path testing]] by McCabe who first proposed it, is to test each linearly independent path through the program; in this case, the number of test cases will equal the cyclomatic complexity of the program.<ref>{{cite web|
url=http://users.csc.calpoly.edu/~jdalbey/206/Lectures/BasisPathTutorial/index.html|
title=Basis Path Testing|
author=A J Sojev}}</ref>
 
==Description==
 
[[Image:control flow graph of function with loop and an if statement without loop back.svg|thumb|250px|right|A control flow graph of a simple program. The program begins executing at the red node, then enters a loop (group of three nodes immediately below the red node). On exiting the loop, there is a conditional statement (group below the loop), and finally the program exits at the blue node. This graph has 9 edges, 8 nodes, and 1 [[connected component (graph theory)|connected component]], so the cyclomatic complexity of the program is 9 - 8 + (2*1) = 3.]]
The cyclomatic complexity of a section of source code is the count of the number of linearly independent [[control flow|paths]] through the [[source code]]. For instance, if the source code contained no decision points such as IF statements or FOR loops, the complexity would be 1, since there is only a single path through the code. If the code had a single IF statement containing a single condition, there would be two paths through the code: one path where the IF statement is evaluated as TRUE and one path where the IF statement is evaluated as FALSE.
 
Mathematically, the cyclomatic ''complexity'' of a [[Structured programming|structured program]]<ref group="note">Here "structured" means in particular "with a single exit ([[return statement]]) per function".</ref> is defined with reference to the [[control flow graph]] of the program, a [[directed graph]] containing the [[basic block]]s 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<ref name="mccabe76">{{cite journal|
last=McCabe|
year=1976|month=December|
journal=IEEE Transactions on Software Engineering|
pages=308–320|
title=A Complexity Measure|
url=http://www.literateprogramming.com/mccabe.pdf|
format=}} {{working link|date=March 2012}}</ref>
 
:''M'' = ''E'' &minus; ''N'' + 2''P'',
 
where
:''E'' = the number of edges of the graph,
:''N'' = the number of nodes of the graph,
:''P'' = the number of [[connected component (graph theory)|connected components]] (exit nodes).
 
[[Image:control flow graph of function with loop and an if statement.svg|thumb|250px|right|The same function as above, shown as a ''strongly connected'' control flow graph, for calculation via the alternative method. This graph has 10 edges, 8 nodes, and 1 [[connected component (graph theory)|connected component]], so the cyclomatic complexity of the program is 10 - 8 + 1 = 3.]] <!-- Do not change this to 4.  This has been done twice, but 3 is the correct answer.  Read the paragraph below for the explanation of why: -->
An alternative formulation is to use a graph in which each exit point is connected back to the entry point. In this case, the graph is said to be ''strongly connected'', and the cyclomatic complexity of the program is equal to the cyclomatic ''number'' of its graph (also known as the [[Betti_number#Example:_the_first_Betti_number_in_graph_theory|first Betti number]]), which is defined as<ref name="mccabe76" />
:''M'' = ''E'' &minus; ''N'' + ''P''.
 
This may be seen as calculating the number of [[linearly independent cycle]]s that exist in the graph, i.e. those cycles that do not contain other cycles within themselves. Note that because each exit point loops back to the entry point, there is at least one such cycle for each exit point.
 
For a single program (or subroutine or method), ''P'' is always equal to 1. Cyclomatic complexity may, however, be applied to several such programs or subprograms at the same time (e.g., to all of the methods in a class), and in these cases ''P'' will be equal to the number of programs in question, as each subprogram will appear as a disconnected subset of the graph.
 
It can be shown that the cyclomatic complexity of any structured program with only one entrance point and one exit point is equal to the number of decision points (i.e., "if" statements or conditional loops) contained in that program plus one.<ref name="mccabe76"/><ref name="ecst">{{cite book|
title=Encyclopedia of Computer Science and Technology|
author=Belzer, Kent, Holzman and Williams|
publisher=CRC Press|year=1992|
pages=367–368}}</ref>
 
Cyclomatic complexity may be extended to a program with multiple exit points; in this case it is equal to:
:π − ''s'' + 2,
where π is the number of decision points in the program, and ''s'' is the number of exit points.<ref name="ecst" /><ref name="harrison">{{cite journal|
journal=Software: Practice and Experience|
title=Applying Mccabe's complexity measure to multiple-exit programs|
author=Harrison|
date=October 1984|
publisher=J Wiley & Sons}}</ref>
 
=== Formal definition ===
An ''even subgraph'' of a graph (also known as an [[Eulerian path|Eulerian subgraph]]) is one where every vertex is incident with an even number of edges; such subgraphs are unions of cycles and isolated vertices. In the following, even subgraphs will be identified with their edge sets, which is equivalent to only considering those even subgraphs which contain all vertices of the full graph.
 
The set of all even subgraphs of a graph is closed under [[symmetric difference]], and may thus be viewed as a vector space over [[GF(2)]]; this vector space is called the ''cycle space'' of the graph. The ''cyclomatic number'' of the graph is defined as the dimension of this space. Since GF(2) has two elements and the cycle space is necessarily finite, the cyclomatic number is also equal to the 2-logarithm of the number of elements in the cycle space.
 
A basis for the cycle space is easily constructed by first fixing a [[Glossary of graph theory#Trees|maximal spanning forest]] of the graph, and then considering the cycles formed by one edge not in the forest and the path in the forest connecting the endpoints of that edge; these cycles constitute a basis for the cycle space. Hence, the cyclomatic number also equals the number of edges not in a maximal spanning forest of a graph. Since the number of edges in a maximal spanning forest of a graph is equal to the number of vertices minus the number of components, the formula <math>E-N+P</math> above for the cyclomatic number follows.<ref>{{cite book
|last=Diestel
|first=Reinhard
|title=Graph theory
|edition=2
|series=Graduate texts in mathematics '''173'''
|year=2000
|publisher=Springer
|location=New York
|isbn=0-387-98976-5
}}</ref>
 
For the more topologically inclined, cyclomatic complexity can alternatively be defined as a relative [[Betti number]], the size of a [[relative homology]] group:
:<math>M := b_1(G,t) := \operatorname{rank}H_1(G,t),</math>
which is read as "the first homology of the graph ''G'', relative to the terminal nodes ''t''". This is a technical way of saying "the number of linearly independent paths through the flow graph from an entry to an exit", where:
* "linearly independent" corresponds to homology, and means one does not double-count backtracking;
* "paths" corresponds to ''first'' homology: a path is a 1-dimensional object;
* "relative" means the path must begin and end at an entry or exit point.
 
This corresponds to the intuitive notion of cyclomatic complexity, and can be calculated as above.
 
Alternatively, one can compute this via absolute Betti number (absolute homology – not relative) by identifying (gluing together) all terminal nodes on a given component (or equivalently, draw paths connecting the exits to the entrance), in which case (calling the new, augmented graph <math>\tilde G</math>, which is {{what|reason=something is missing here|date=November 2013}}), one obtains:
:<math>M = b_1(\tilde G) = \operatorname{rank}H_1(\tilde G).</math>
 
It can also be computed via [[homotopy]].  If one considers the control flow graph as a 1-dimensional [[CW complex]] called <math>X</math>, then the [[fundamental group]] of <math>X</math> will be <math>\pi_1(X) = \Z^n</math>.  The value of <math>n+1</math> is the cyclomatic complexity.  The fundamental group counts how many loops there are through the graph, up to homotopy, and hence aligns with what we would intuitively expect.
 
This corresponds to the characterization of cyclomatic complexity as "number of loops plus number of components".
 
=== Etymology / naming ===
 
The name '''cyclomatic complexity''' presents some confusion, as this metric does not only count cycles ([[program loop|loops]]) in the program. Instead, the name refers to the number of different cycles ''in the program control flow graph'', after having added an imagined branch back from the exit node to the entry node.<ref name="mccabe76" />
 
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".<ref name="mccabe76 p. 315">{{cite journal |last=McCabe |year=1976 |month=December |journal=IEEE Transactions on Software Engineering |pages=315 |title=A Complexity Measure}}</ref>
 
==Applications==
 
=== Limiting complexity during development ===
 
One of McCabe's original applications was to limit the complexity of routines during program development; he recommended that programmers should count the complexity of the modules they are developing, and split them into smaller modules whenever the cyclomatic complexity of the module exceeded 10.<ref name="mccabe76" /> This practice was adopted by the [[NIST]] Structured Testing methodology, with an observation that since McCabe's original publication, the figure of 10 had received substantial corroborating evidence, but that in some circumstances it may be appropriate to relax the restriction and permit modules with a complexity as high as 15. As the methodology acknowledged that there were occasional reasons for going beyond the agreed-upon limit, it phrased its recommendation as: "For each module, either limit cyclomatic complexity to [the agreed-upon limit] or provide a written explanation of why the limit was exceeded."<ref name="nist">{{cite web|
url=http://hissa.nist.gov/HHRFdata/Artifacts/ITLdoc/235/title.htm|
title=Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric|
author=McCabe, Watson|
year=1996}}</ref>
 
=== Implications for software testing ===
 
Another application of cyclomatic complexity is in determining the number of test cases that are necessary to achieve thorough test coverage of a particular module.
 
It is useful because of two properties of the cyclomatic complexity, ''M'', for a specific module:
*''M'' is an upper bound for the number of test cases that are necessary to achieve a complete [[branch coverage]].
*''M'' is a lower bound for the number of paths through the control flow graph (CFG). Assuming each test case takes one path, the number of cases needed to achieve [[path coverage]] is equal to the number of paths that can actually be taken. But some paths may be impossible, so although the number of paths through the CFG is clearly an upper bound on the number of test cases needed for path coverage, this latter number (of ''possible'' paths) is sometimes less than ''M''.
 
All three of the above numbers may be equal: branch coverage <math>\leq</math> cyclomatic complexity <math>\leq</math> number of paths.
 
For example, consider a program that consists of two sequential if-then-else statements.
 
<source lang=c>
if( c1() )
  f1();
else
  f2();
 
if( c2() )
  f3();
else
  f4();
</source>
 
[[File:Control flow graph of function with two if else statements.svg|thumb|250px|right|The control flow graph of the source code above; the red circle is the entry point of the function, and the blue circle is the exit point. The exit has been connected to the entry to make the graph strongly connected.]]
In this example, two test cases are sufficient to achieve a complete branch coverage, while four are necessary for complete path coverage. The cyclomatic complexity of the program is 3 (as the strongly connected graph for the program contains 9 edges, 7 nodes and 1 connected component) (9-7+1).
 
In general, in order to fully test a module all execution paths through the module should be exercised. This implies a module with a high complexity number requires more testing effort than a module with a lower value since the higher complexity number indicates more pathways through the code. This also implies that a module with higher complexity is more difficult for a programmer to understand since the programmer must understand the different pathways and the results of those pathways.
 
Unfortunately, it is not always practical to test all possible paths through a program. Considering the example above, each time an additional if-then-else statement is added, the number of possible paths doubles. As the program grew in this fashion, it would quickly reach the point where testing all of the paths was impractical.
 
One common testing strategy, espoused for example by the NIST Structured Testing methodology, is to use the cyclomatic complexity of a module to determine the number of [[white-box testing|white-box tests]] that are required to obtain sufficient coverage of the module. In almost all cases, according to such a methodology, a module should have at least as many tests as its cyclomatic complexity; in most cases, this number of tests is adequate to exercise all the relevant paths of the function.<ref name="nist"/>
 
As an example of a function that requires more than simply branch coverage to test accurately, consider again the above function, but assume that to avoid a bug occurring, any code that calls either f1() or f3() must also call the other.<ref group="note">This is a fairly common type of condition; consider the possibility that f1 allocates some resource which f3 releases.</ref> Assuming that the results of c1() and c2() are independent, that means that the function as presented above contains a bug.  Branch coverage would allow us to test the method with just two tests, and one possible set of tests would be to test the following cases:
 
* c1() returns true and c2() returns true
* c1() returns false and c2() returns false
 
Neither of these cases exposes the bug. If, however, we use cyclomatic complexity to indicate the number of tests we require, the number increases to 3. We must therefore test one of the following paths:
 
* c1() returns true and c2() returns false
* c1() returns false and c2() returns true
 
Either of these tests will expose the bug.
 
===Cohesion===
 
One would also expect that a module with higher complexity would tend to have lower [[cohesion (computer science)|cohesion]] (less than functional cohesion) than a module with lower complexity. The possible correlation between higher complexity measure with a lower level of cohesion is predicated on a module with more decision points generally implementing more than a single well defined function. A 2005 study showed stronger correlations between complexity metrics and an expert assessment of cohesion in the classes studied than the correlation between the expert's assessment and metrics designed to calculate cohesion.<ref>{{cite journal|
journal=Journal of Computer Science|
author=Stein et al|
url=http://thescipub.com/abstract/10.3844/jcssp.2005.137.144|
title=Exploring the relationship between cohesion and complexity|
year=2005|volume=1|issue=2|pages=137–144|
doi=10.3844/jcssp.2005.137.144|
last2=Cox|
first2=Glenn|
last3=Etzkorn|
first3=Letha}}</ref>
 
===Correlation to number of defects===
 
A number of studies have investigated cyclomatic complexity's correlation to the number of defects contained in a function or method.{{Citation needed|date=December 2012}}  Some{{Citation needed|date=December 2012}} studies find a positive correlation between cyclomatic complexity and defects: functions and methods that have the highest complexity tend to also contain the most defects, however the correlation between cyclomatic complexity and program size has been demonstrated many times and since program size is not a controllable feature of commercial software the usefulness of McCabes's number has been called to question. The essence of this observation is that larger programs (more complex programs as defined by McCabe's metric) tend to have more defects. Although this relation is provably true, it isn't commercially useful<ref name=cherf>{{cite journal|
journal=Journal of Software Quality|
author=G.S. Cherf|
url=http://link.springer.com/article/10.1007%2FBF01720922?LI=true|
title=An Investigation of the Maintenance and Support Characteristics of Commercial Software|
year=1992|volume=1|issue=3|pages=147–158|
publisher=Springer-Verlag|
issn=1573-1367}}</ref>
. As a result the metric has not been accepted by commercial software development organizations.
 
Studies that controlled for program size (i.e., comparing modules that have different complexities but similar size, typically measured in [[lines of code]]) are generally less conclusive, with many finding no significant correlation, while others do find correlation. Some researchers who have studied the area question the validity of the methods used by the studies finding no correlation.<ref name="kan">{{cite book|
title=Metrics and Models in Software Quality Engineering|
author=Kan|
pages=316–317|
publisher=Addison-Wesley|
year=2003|
isbn=0-201-72915-6}}</ref>
 
[[Les Hatton]] claimed (Keynote at TAIC-PART 2008, Windsor, UK, Sept 2008) that McCabe's Cyclomatic Complexity number has the same predictive ability as lines of code.<ref name="taic">{{cite web |
url=http://www.leshatton.org/2008/08/the-role-of-empiricism-in-improving-the-reliability-of-future-software/|
title=The role of empiricism in improving the reliability of future software|
author=Les Hatton|
year=2008| at = version 1.1}}</ref>
 
==See also==
* [[Complexity]]
* [[Complexity trap]]
* [[Computer program]]
* [[Computer programming]]
* [[Control flow]]
* [[Decision-to-decision path]]
* [[Design predicates]]
* [[Essential complexity]]
* [[Halstead complexity measures]]
* [[Panopticode]]
* [[Software engineering]]
* [[Software testing]]
* [[Static program analysis]]
* [[Synchronization Complexity]]
* [[Maintainability]]
 
==Notes==
<references group="note" />
 
==References==
{{reflist}}
 
==External links==
*[http://www.mathworks.com/discovery/cyclomatic-complexity.html Generating cyclomatic complexity metrics with Polyspace]
*[http://www.literateprogramming.com/mccabe.pdf A Complexity Measure] (McCabe's original paper in IEEE Transactions on Software Engineering Vol. 2, No. 4, p.&nbsp;308 (1976))
*[http://hissa.ncsl.nist.gov/sw_assurance/strtest.html Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric] NIST Special Publication 500-235
*[http://www.leshatton.org/Documents/TAIC2008-29-08-2008.pdf The role of empiricism in improving the reliability of future software]
*[http://www.venkatreddy.in/2007/10/04/non-linear-paths-from-application-code/ Non linear paths from Application Code]
*[https://sites.google.com/site/maltapplication/ A small C/C++ source code analyzer using the cyclometric complexity metric]
 
[[Category:Software metrics]]

Latest revision as of 03:20, 12 April 2014

BIG APPLE - Jay Victorino was standing exterior his mother's condominium when he was grabbed by police, and he says if she hadn't come downstairs to establish him he would've been arrested on a trespassing charge.

Mental property legislation impacts many areas of our lives, instantly and not directly. Understanding mental property laws can subsequently assist us to grasp the basic processes concerned in coping with intellectual property in its many manifestations. This course is beneficial for individuals who work in numerous business and industrial settings. It would also be appropriate for those with an interest within the artistic industries. Many Singaporeans have been investing in property throughout the causeway in recent years, attracted by comparatively low prices. Nevertheless, those that have to exit their investments shortly are likely to face vital challenges when trying to sell their property – and could ultimately be stuck with a property they cannot promote.

Mr. Pua was previously the Chief Government Officer of DLF Worldwide Holdings Pte. Ltd., the international enterprise arm of DLF Limited, India's largest real property company. He was also Chief Government Officer of various CapitaLand Group of corporations, together with CapitaLand Retail Limited (now referred to as CapitaMalls Asia Restricted), CapitaLand Monetary Restricted and CapitaMall Belief Management Restricted. He was a Director on the Board of CapitaRetail China Belief Administration Restricted and The HYPERLINK Management Restricted.

The Holland district (district 10) is one of the three most desired districts best condo in singapore Singapore (the others being districts 8 and 9). This is not solely as a result of its nice location and proximity to town, its personal residential estates and a bunch of center-class conveniences but in addition due to its pleasant environment. Singapore ought to remain a haven for capital when markets are as unstable and opaque as they are," said stated Tim Gibson, co-head for Henderson Horizon World Property Equities Fund & supervisor of the Henderson Horizon Asia Pacific Property Equities Fund. D19) Hougang / Punggol / Sengkang Apartment Common Room with Aircon D22) Boon Lay / Jurong / Tuas Condominium Common Room with Aircon An EC with Iconic Skypark! Put up your Property Model New Condos Rental Revenue

The acquisition seems well timed. San Jose is witnessing a rise in investor urge for food for commercial tasks on the back of a increase within the tech sector. Developers like San Franciso-primarily based Simeon Residential Properties, Cupertino-primarily based KT Properties and Essen Property Belief are respiration new life into the realm that has so long been a laggard in Silicon Valley. Given its cut price worth, Vietnam City seems properly poised to faucet into the market's new buoyancy.

Whenever you sell Property, your lawyer's primary duty is to make sure that oncompletion, you might be ready to ship the title to the property free from your mortgageand CPF charge. This requires your lawyer to liaise with your bank's and CPF Board'slawyer for fee, out of the sale proceeds, the outstanding mortgage amount and refundof your CPF funds enough to discharge the financial institution's mortgage and CPF charge. HDB Flats You are advised to contact the HDB instantly in respect of the sale and/or purchaseof HDB flats. The HDB has devised their own type of Settlement/Contract for the purchaseof HDB flats. When doing all of your sums, you ought to be conscious that as a international investor, the rent you obtain from your property can be topic to withholding tax.