title: Calculate alters density in a large graph in R
body: <p>I'm working with a large social network in R (560120 ties). I want to calculate the local density of nodes, as well as the density of their alters.</p>
  <p>I achieved the former with the following code snippet, using the package <code>igraph</code>.</p>
  <pre><code> g &lt;- graph_from_data_frame(edgelist, directed = FALSE)
   egonet_list &lt;- make_ego_graph(g)
  
   dat &lt;- data.frame(
      id = names(V(g),
      egonet_density = lapply(egonet_list, graph.density) %&gt;% unlist()
    )
  </code></pre>
  <p>However, I run into memory troubles when I try to calculate the network of ego's alters. I try to run the following:</p>
  <pre><code>alter_list &lt;- make_ego_graph(g, order = 2, mindist = 1)
  </code></pre>
  <p>It does work for smaller graphs, but with my network setup, it is eating up all of my RAM (&gt;110GB) and crashing.</p>
  <p>Does anyone have a suggestion how to solve this issue in a memory-friendly way?</p>