Cellular shortest distance (mathematical induction + breadth-first algorithm) C language implementation