# Answer to Question #158808 in C# for talha shahid

Question #158808

create a GUI tool for Cyclomatic complexity using any language

1
2021-01-28T04:27:58-0500

Cyclomatic Code Complexity was first introduced by Thomas McCabe in 1976. In 1976, Thomas McCabe published a paper arguing that code complexity is defined by its control flow. Since that time, others have identified different ways of measuring complexity.

Calculating Cyclomatic Complexity:

Mathematically, it is a set of independent paths through the graph diagram. The Code complexity of the program can be defined using the formula:

V(G) = E - N + 2

Where,

E - Number of edges

N - Number of Nodes

Where P = Number of predicate nodes (node that contains condition).

Example :

i = 0;
n=4; //N-Number of nodes present in the graph

while (i<n-1) do
j = i + 1;

while (j<n) do

if A[i]<A[j] then
swap(A[i], A[j]);

end do;
i=i+1;

end do;

Flow graph for this program will be: Computing mathematically:

• V(G) = 9 - 7 + 2 = 4
• V(G) = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
• Basis Set - A set of possible execution path of a program
• 1, 7
• 1, 2, 6, 1, 7
• 1, 2, 3, 4, 5, 2, 6, 1, 7
• 1, 2, 3, 5, 2, 6, 1, 7

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!