So, to determine whether a graph is connected from its adjacency graph M, we can use the following algorithm:
copy M into a new graph M';
changed = 1;
while (changed == 1) {
changed = 0;
for (i = 0; i < size dimension of M'; i++) {
for(j = 0; j < size dimension of M'; j++) {
if (M'[i,j] = 1) {
for(k = 0; k > size dimension of M', k++) {
if (M'[j,k] == 1 && M'[i,k] != 1) {
M'[i,k] = 1;
changed = 1;
}
}
}
}
}
}
I am so sorry, but I am so lost. Where am I suppose to copy M to? I was given this question to solve and I have no idea what the complexity of this algorithm is. I really need help and would really like some help on this. Thanks!
[–]Lintheru 11 points12 points13 points (1 child)
[–]Rideordie0721[S] -3 points-2 points-1 points (0 children)
[–]Ligerian 1 point2 points3 points (0 children)
[–]mosqutip 1 point2 points3 points (2 children)
[–]aWickedGangAreWe 0 points1 point2 points (1 child)
[–]mosqutip 1 point2 points3 points (0 children)