── Column specification ────────────────────────────────────────────────────────
dbl (100): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
x =as.matrix(x)
Create a matrix and use some kind of graph movement.
define_edges =function(i, j) {if (i ==1& j ==1) { e =list(c(1,0), c(0,1)) } elseif (i ==1& j ==100) { e =list(c(1,0), c(0,-1)) } elseif (i ==100& j ==1) { e =list(c(-1,0), c(0,1)) } elseif (i ==100& j ==100) { e =list(c(-1,0), c(0,-1)) } elseif (i ==1) { e =list(c(1,0), c(0,1), c(0,-1)) } elseif (j ==1) { e =list(c(-1,0), c(1,0), c(0,1)) } elseif (i ==100) { e =list(c(-1,0), c(0,1), c(0,-1)) } elseif (j ==100) { e =list(c(-1,0), c(1,0), c(0,-1)) } else { e =list(c(1,0), c(0,1), c(-1,0), c(0,-1)) }return(e)}
g =make_empty_graph(n=10000, directed=TRUE)for (i in1:100) { for (j in1:100) { # define edges that we can move on e =define_edges(i,j)for (d in e) { a = i + d[1] b = j + d[2] outo = (a-1)*100+ b # from this node into = (i-1)*100+ j # into this node# cat(outo, into, "\n")# print(into) g =add_edges(g, c(outo,into), weight=x[i,j]) } }}