title: Detect bi-cliques in r for bipartite graph
body: <p>I am trying to recreate the Biclique Communities method (<a href="http://journals.aps.org/pre/abstract/10.1103/PhysRevE.78.016108" rel="nofollow noreferrer">Lehmann, Schwartz, &amp; Hansen, 2008</a>) in R which relies on the definition of a Ka,b biclique. The example below shows two adjacent K2,2 bicliques - the first clique is {A,B,1,2} and the second clique is {B,C,2,3}. I would like to be able to identify these cliques using R so that I can apply this to a broader dataset.</p>
  
  <p><img src="https://i.stack.imgur.com/K8UNT.png" alt="Adjacent K2,2 Bicliques"></p>
  
  <p>I have included my attempt so far in R and I am stuck with the following two issues:</p>
  
  <ol>
  <li>If I use the standard walktrap.community it recognises the communities but does not allow the set {B,2} to belong in both cliques</li>
  <li>If I use an updated <a href="http://igraph.wikidot.com/community-detection-in-r" rel="nofollow noreferrer">clique.community</a> function this doesn't seem to identify the cliques or I don't understand correctly (or both)</li>
  </ol>
  
  <p><strong>Example code:</strong></p>
  
  <pre><code>library(igraph)
  
  clique.community &lt;- function(graph, k) {
    clq &lt;- cliques(graph, min=k, max=k)
    edges &lt;- c()
    for (i in seq_along(clq)) {
      for (j in seq_along(clq)) {
        if ( length(unique(c(clq[[i]], clq[[j]]))) == k+1 ) {
          edges &lt;- c(edges, c(i,j))
        }
      }
    }
    clq.graph &lt;- simplify(graph(edges))
    V(clq.graph)$name &lt;- seq_len(vcount(clq.graph))
    comps &lt;- decompose.graph(clq.graph)
  
    lapply(comps, function(x) {
      unique(unlist(clq[ V(x)$name ]))
    })
  }
  
  users &lt;- c('A', 'A', 'B', 'B', 'B', 'C', 'C')
  resources &lt;- c(1, 2, 1, 2, 3, 2, 3)
  cluster &lt;- data.frame(users, resources)
  matrix &lt;- as.data.frame.matrix(table(cluster))
  
  igraph &lt;- graph.incidence(matrix)
  
  clique.community(igraph, 2)
  walktrap.community(igraph)
  </code></pre>