bfs algo.
Modified the computation of Wik and Rik, but the function is still not correct (probably some indexes).
Debugs.