title: Finding second degree intersection from intersection matrix
body: <p>I have n rectangles and I need to find how many of them overlap. Which I have done and created an intersection matrix which looks like this <a href="https://i.stack.imgur.com/jrqzl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jrqzl.png" alt="Intersection Matrix"></a> for the below JSON where each entry presents a rectangle and 1 represents there is an overlap. It is a symmetric matrix and i have assumed that a rectangle overlaps itself.</p>
  
  <pre><code>{
   "rects": [
            {"x": 100, "y": 100, "w": 250, "h": 80 },
            {"x": 120, "y": 200, "w": 250, "h": 150 },
            {"x": 140, "y": 160, "w": 250, "h": 100 },
            {"x": 160, "y": 140, "w": 350, "h": 190 }
            ]
   }
  </code></pre>
  
  <p>Now I know that there can be 2 or more rectangles overlapping each other. How can I find them using this intersection matrix? Or is there any other approach for this?</p>
  
  <p>e.g 1,3,4 and 2,3,4</p>