我有邻接列表,如下所示 - dput(data)
list(c(2L, 3L, 5L, 6L, 7L, 8L, 9L, 11L, 12L, 13L, 14L, 18L, 22L,
32L), c(1L, 3L, 4L, 8L, 14L, 18L, 20L, 31L), c(2L, 4L, 9L, 10L,
14L, 28L, 29L, 33L), c(1L, 2L, 3L, 8L, 13L), c(1L, 7L, 11L),
c(1L, 11L, 17L), c(5L, 6L, 17L), c(1L, 3L, 4L), c(1L, 3L,
31L, 34L), c(3L, 34L, 33L), c(1L, 5L, 6L), c(1L, 32L, 23L
), c(1L, 4L, 2L), c(1L, 2L, 4L, 34L), c(33L, 34L, 29L), c(33L,
34L, 33L), c(6L, 7L, 19L), c(1L, 2L, 10L), c(33L, 34L, 14L
), c(1L, 2L, 34L), c(33L, 34L, 26L), c(1L, 2L, 15L), c(33L,
34L, 6L), c(26L, 28L, 33L, 34L), c(26L, 28L, 32L), c(24L,
25L, 32L), c(30L, 34L, 20L), c(3L, 24L, 34L), c(3L, 32L,
34L), c(24L, 27L, 33L), c(9L, 33L, 34L), c(1L, 25L, 26L,
33L), c(3L, 9L, 15L, 16L, 19L, 21L, 24L, 30L, 31L, 32L, 34L
), c(9L, 10L, 14L, 15L, 16L, 19L, 21L, 23L, 24L, 28L, 29L,
30L, 31L, 32L, 33L))
该列表类似于邻接列表,我想将其转换为R中的igraph对象。我尝试过使用
graph_from_data_frame(data, directed = FALSE, vertices = NULL)
但它不起作用。我也试过
graph_from_adj_list(data,mode="all",duplicate=FALSE)
但是这给出了错误的图表。例如,1-> 2,3,5,6
的边应为1->2,1->3,1->5,1-6
;但它同时给出随机输出1->3,2->5,3->6,2->6
...
任何想法,如何在R?