I am currently trying to (ideally) use igraph to generate a cycle graph adjacency matrix. I would like each unit to be neighbors with k people.
For k = 2, I am hoping to get:
library(igraph)
as_adj(make_graph(c(1, 2, 1, 10, 2, 3, 3, 4, 4, 5 ,5,6, 6,7, 7,8, 8,9, 9, 10), directed = FALSE))
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0 1 0 0 0 0 0 0 0 1
[2,] 1 0 1 0 0 0 0 0 0 0
[3,] 0 1 0 1 0 0 0 0 0 0
[4,] 0 0 1 0 1 0 0 0 0 0
[5,] 0 0 0 1 0 1 0 0 0 0
[6,] 0 0 0 0 1 0 1 0 0 0
[7,] 0 0 0 0 0 1 0 1 0 0
[8,] 0 0 0 0 0 0 1 0 1 0
[9,] 0 0 0 0 0 0 0 1 0 1
[10,] 1 0 0 0 0 0 0 0 1 0
Is there a way to use existing functions in igraph
to create graphs such as the one above, but for a generic k? Thanks.