r - Find biggest independent subset of a connectivity matrix -


i have 2 groups linked connectivity matrix following:

# #   x1  x2  x3  x4  x5  x6 #   1   0   0   0   0   0  v1 #   1   1   1   0   0   0  v2   #   0   1   0   0   0   0  v3 #   0   0   1   0   0   0  v4 #   0   0   0   1   0   0  v5 #   0   0   0   1   0   0  v6 #   0   0   0   0   1   0  v7 #   0   0   0   0   1   1  v8 #   0   0   0   0   1   0  v9 #   0   0   0   0   0   1  v10 #  

so x1 linked v1 , v2 while v2 linked x1, x2 , x3 , on. need find way (algorithm or command) getting biggest independent subsets of matrix. so, in case:

#   x1  x2  x3  #   1   0   0  v1 #   1   1   1  v2   #   0   1   0  v3 #   0   0   1  v4 

and:

#   x4 #   1  v5 #   1  v6 

and:

#   x5  x6  #   1   0   v7 #   1   1   v8   #   1   0   v9 #   0   1   v10 

do have hint? guess there's library or function use either graph analysis or linear algebra.

as hinted can igraph:

# dummy data df1 <- read.table(text = "  x1  x2  x3  x4  x5  x6 v1  1   0   0   0   0   0                   v2    1   1   1   0   0   0                   v3    0   1   0   0   0   0                   v4    0   0   1   0   0   0                   v5    0   0   0   1   0   0                   v6    0   0   0   1   0   0                   v7    0   0   0   0   1   0                   v8    0   0   0   0   1   1                   v9    0   0   0   0   1   0                   v10   0   0   0   0   0   1                   ")  library(dplyr) library(tidyr) library(igraph)  # make graph object gg <-    df1 %>%    add_rownames(var = "v") %>%    gather(x, value, -v) %>%    filter(value == 1) %>%    graph.data.frame  # split based on clusters of graph lapply(   sapply(split(clusters(gg)$membership,                clusters(gg)$membership), names),   function(i)   df1[intersect(rownames(df1), i),       intersect(colnames(df1), i),       drop = false])  # $`1` #    x1 x2 x3 # v1  1  0  0 # v2  1  1  1 # v3  0  1  0 # v4  0  0  1 #  # $`2` #    x4 # v5  1 # v6  1 #  # $`3` #     x5 x6 # v7   1  0 # v8   1  1 # v9   1  0 # v10  0  1 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo