percolate.board: percolate

Description Usage Arguments Value Examples

View source: R/percolate.R

Description

percolate

Usage

1
2
## S3 method for class 'board'
percolate(start_board)

Arguments

start_board

a board object to be percolated

Value

a list containing the field result: a T/F indicating whether or not the board percolated and result_board: a board object after the percolation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
m = board(generate_board_mat(n = 100, p = 0.4)); plot(percolate(m)$result_board)


mat_example_list <- list(matrix(c(1,1,1,1,0,
0,0,0,1,0,
1,1,1,1,0,
0,1,0,0,0,
0,1,1,1,1), 5, 5),
matrix(c(1,1,1,1,0,
        0,0,0,1,0,
        0,1,1,1,0,
        0,1,0,0,0,
        0,1,1,1,1), 5, 5),
matrix(c(1,1,1,1,0,
        0,0,0,1,0,
        0,1,1,0,0,
        0,1,0,0,0,
        0,1,1,1,1), 5, 5))

mat_boards = lapply(mat_example_list, FUN = board)
mat_perc_boards = lapply(mat_boards, FUN = function(b)(percolate(b)$result_board))
all = c(mat_boards, mat_perc_boards)
mat_plots = lapply(all, FUN = plot)
library(gridExtra)
grid.arrange(grobs = mat_plots, ncol = 3, nrow = 2)

Achowdh1/percolate documentation built on Oct. 30, 2019, 4:09 a.m.