R - "max subgraphs" 图中

R - "max subgraphs" in graph

我想识别给定图中的最大子图

例如,对于这些图表:

和这段代码:

    library("igraph")        
    from <- c(1,2,3,3,6,6,8,9)
    to <- c(2,3,4,5,7,8,6,10)
    edges = data.frame(from,to)
    g<- graph_from_data_frame(edges,directed=FALSE)
    plot(g)

    clc <- max_cliques(g, min=3)
    clc

max cliques with min=3 给我 empty list...

我想要得到的结果(最小值=3)是:

(1,2,3,4,5) (6,7,8)

我想你要找的不是团,而是连通分量。

在您的图表中,派系(完整 子图)的大小为 2 或更小,因此函数 max_cliques 不会 return 如果您将最小尺寸设置为 3。

另一方面,您可以使用函数 clusters 来查找图形的最大连通分量。

cl <- clusters(g)
me <- which(cl$csize >= 3)
res <- split(names(cl$membership), cl$membership)[me]
res
$`1`
[1] "1" "2" "3" "4" "5"

$`2`
[1] "6" "8" "7"