title: Find and count the number of isolated and semi-isolated nodes in a network
body: <p>I am working with networks undergoing a number of <strong>disrupting events</strong>. So, a number of nodes fail because of a given event. Therefore there is a transition between the image to the left to that to the right:</p>
  
  <p><a href="https://i.stack.imgur.com/CGDWt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CGDWt.png" alt="enter image description here"></a></p>
  
  <p><strong>My question:</strong> how can I find <em>the disconnected subgraphs</em>, even if they contain only 1 node? My purpose is to <strong>count</strong> them and render <strong>as failed</strong>, as in my study this is what applies to them. By semi-isolated nodes, I mean <em>groups of isolated nodes, but connected to each other</em>.</p>
  
  <p>I know I can find isolated nodes like this:</p>
  
  <pre><code>def find_isolated_nodes(graph):
      """ returns a list of isolated nodes. """
      isolated = []
      for node in graph:
          if not graph[node]:
              isolated += node
      return isolated
  </code></pre>
  
  <p>but how would you amend these lines to make them find groups of isolated nodes as well, like those highlighted in the right hand side picture? </p>
  
  <p><strong>MY THEORETICAL ATTEMPT</strong></p>
  
  <p>It looks like this problem is addressed by the <strong>Flood Fill</strong> algorithm, which is explained <a href="https://en.wikipedia.org/wiki/Flood_fill" rel="nofollow noreferrer">here</a>. However, I wonder how it could be possible to simply count the number of nodes in the giant component(s) and then subtract it from the number of nodes that appear still active at stage 2. How would you implement this?</p>