To calculate the cyclic complexity of the code, I drew a control block diagram consisting of nodes and edges that helped me calculate V (G) = EN + 2 In my case, E = 15 and N = 11. As a result, the cyclomatic complexity is 6.
Now, to confirm my answer, I would like to help find linearly independent paths for hitting the code:
int maxValue = m[0][0];
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if ( m[i][j] > maxValue )
{
maxValue = m[i][j];
}
}
}
cout << maxValue << endl;
int sum = 0;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
sum = sum + m[i][j];
}
}
cout << sum << endl;
This should equal the result for my V (G), otherwise my calculation is wrong. Thank you for your help.
source
share