Template Function ADS::gridDistances

Function Documentation

template<class Free, class Moves = FourMoves>
std::vector<std::vector<int>> ADS::gridDistances(int rows, int cols, const std::vector<GridCell> &sources, Free &&free, const Moves &moves = FOUR_MOVES)

gridDistances(): the distance in moves of each cell of the rows x cols grid from the nearest source, INF if none reaches it, entering only the cells x with free( x ); D[ r ][ c ] for the cell ( r , c )

Pre:

rows , cols >= 0, the sources are free cells of the grid

Post:

0 on the sources, and each other reached cell one move farther than a neighbour from which it can be reached (audit)