r - Construct an actor-by-clique matrix after kCliques in RBGL -


after running kcliques in rbgl, have list comprised of cliques , members.

i wish construct member-by-clique matrix list object created kcliques.

as example:

con <- file(system.file("xml/snacliqueex.gxl",package="rbgl")) coex <- fromgxl(con) close(con) kcl <- kcliques(coex) 

which results in

kcl<-structure(list(`1-cliques` = list(c("1", "2", "3"), c("2", "4"),      c("3", "5"), c("4", "6"), c("5", "6")), `2-cliques` = list(     c("1", "2", "3", "4", "5"), c("2", "3", "4", "5", "6")),      `3-cliques` = list(c("1", "2", "3", "4", "5", "6"))),      .names = c("1-cliques", "2-cliques", "3-cliques")) 

kcl list elements character vectors indicating clique members. wish construct member-by-clique matrix cell i,j indicates whether node member of clique j.

here transformations should work

#remove 1 level of nesting x <- do.call("c", kcl); #assign number each cliqeq xx <- do.call("rbind", map(function(x,y) data.frame(x,y), x, seq_along(x)));  #track participation xtabs(~x+y, xx) 

which gives

   y x   1 2 3 4 5 6 7 8   1 1 0 0 0 0 1 0 1   2 1 1 0 0 0 1 1 1   3 1 0 1 0 0 1 1 1   4 0 1 0 1 0 1 1 1   5 0 0 1 0 1 1 1 1   6 0 0 0 1 1 0 1 1 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -