Input: The set of obstacle spatial distribution, ; the side length of gird, . | Output: The adjacency matrix of grid connectivity, . | 1 Initialize a matrix with 0, the shape of is (). | 2 for each do | 3 for each do | 4 // Determine whether the current grid is an obstacle grid | 5 ifthen | 6 else | 7 ifthen | 8 else ifthen | 9 // Determine the connectivity of front. | 10 ifthen, , 1 | 11 // Determine the connectivity of left. | 12 else if & then, , 1 | 13 else ifthen | 14 ifthen, , 1 | 15 end if | 16 // Determine the connectivity of right. | 17 if & then, , 1 | 18 end if | 19 // Determine the connectivity of front left. | 20 else if & then, , 1 | 21 // Determine the connectivity of front right. | 22 else if & & then, , 1 | 23 // Determine the connectivity of back. | 24 else ifthen, , 1 | 25 // Determine the connectivity of back left. | 26 else if & then, , 1 | 27 // Determine the connectivity of back right. | 28 else if & & then, , 1 | 29 end if | 30 end if | 31 end if | 32 end for | 33 end for | 34 final | 35 return |
|