To calculate the cyclomatic complexity of a code, I drew a control flow chart consisting of nodes and edges which helped me to calculate V (G) = E - N + 2 In my case E = 15 and N = 11. Resulting in a cyclomativ complexity of 6.
Now to confirm my answer I would like some help on finding linearly independent paths for the code blow:
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.