Obtain blocks of vertices of a 1D, 2D, or 3D graph, in order to use the conditional independence to speed up the simulation (chequerboard idea).
getBlocks(mask, nblock)
mask | a vector, matrix, or 3D array specifying vertices of a graph. Vertices of value 1 are within the graph and 0 are not. |
---|---|
nblock | a scalar specifying the number of blocks. For a 2D graph |
A list with the number of components equal to nblock
. Each component consists of vertices within the same block.
The vertices within each block are mutually independent given the vertices in other blocks. Some blocks could be empty.
Wilkinson, D. J. (2005) "Parallel Bayesian Computation" Handbook of Parallel Computing and Statistics, pp. 481-512 Marcel Dekker/CRC Press
#Example 1: split a line into 2 blocks getBlocks(mask=c(1,1,1,1,0,0,1,1,0), nblock=2)#> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 2 4 6 #>#Example 2: split a 4*4 2D graph into 4 blocks in order # to use the chequerboard idea for a neighbourhood structure # corresponding to the second-order Markov random field. getBlocks(mask=matrix(1, nrow=4, ncol=4), nblock=4)#> [[1]] #> [1] 6 8 14 16 #> #> [[2]] #> [1] 5 7 13 15 #> #> [[3]] #> [1] 2 4 10 12 #> #> [[4]] #> [1] 1 3 9 11 #>#Example 3: split a 3*3*3 3D graph into 8 blocks # in order to use the chequerboard idea for a neighbourhood # structure based on the 18 neighbors definition, where the # neighbors of a vertex comprise its available # adjacencies sharing the same edges or faces. mask <- array(1, dim=rep(3,3)) getBlocks(mask, nblock=8)#> [[1]] #> [1] 14 #> #> [[2]] #> [1] 13 15 #> #> [[3]] #> [1] 11 17 #> #> [[4]] #> [1] 10 12 16 18 #> #> [[5]] #> [1] 5 23 #> #> [[6]] #> [1] 4 6 22 24 #> #> [[7]] #> [1] 2 8 20 26 #> #> [[8]] #> [1] 1 3 7 9 19 21 25 27 #>