title: R: Extract connected graphs
body: <p>I've a undirected graph composed of ~300 nodes. The graph is composed of multiple connected graphs (example below with a undirected graph composed of 5 connected graph). Using R, how can I extract each connected sub-graph, and their node and edge count. My graph is represented by a two-column data.frame:</p>
  
  <pre><code>node1 node2
  node1 node3
  node2 node5
  ...  
  </code></pre>
  
  <p>With the example below, the expected result would be</p>
  
  <pre><code>Subgraph NodeCount EdgeCount
  1        2         1
  2        4         3
  3        2         1
  4        2         1
  5        2         1
  </code></pre>
  
  <p>Thanks</p>
  
  <p><img src="https://i.stack.imgur.com/s16Xe.png" alt="enter image description here"></p>