Well, that's not so hard to translate the algorithm. I remember I used this algorithm last year, but I haven't got it on my computer, sorry.
Well, what's the problem with it? Do you understand how it works? If yes, what's the problem? It looks pretty simple for me? Maybe your array is not the way you can use in this algorithm? The idea of this algorithm is that you go into the first node, mark it as checked, then select connected nodes to visit on the next loop (probably a vector would be nice for this).
Another, simpler way to do so (and I think that was the way I did last year) is to make a loop from 0 to N-1 (N - a number of nodes, N-1 because the arrays starts at 0) and make another loop in it, which finds the first node, which is not visited and is supposed to be visited. (I had to find the shortest way, so I checked if the way to the node is shorter than the one that exists already.
|