title: Neo4j Cypher: Finding the maximum and minimum node value in every disconnected subgraph and take the difference
body: <p>If I have a graph as shown below. I would like to find the maximum value in a subgraph and minimum value in a subgraph take the difference and return. </p>
  
  <p>For instance the right-most subgraph has 4 nodes. Maximum value is 3 and Minimum value is 1, I would like to take the difference and return, which for this case is 2. This should happen for every disconnected subgraph in the whole graph database. I will prefer to handle each subgraph using one query, that way it can be done in batch and difference for each subgraph can be returned. </p>
  
  <p><a href="https://i.stack.imgur.com/X6Tbo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X6Tbo.png" alt=""></a></p>
  
  <p>I will be thankful to get some intuition.</p>