title: Find how many duplicate connections are in a list of edges [python]
body: <p>Given a list of edges such as, </p>
  
  <pre><code>edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [10, 11], [12, 9], [12, 10]]
  </code></pre>
  
  <p>I need to find how many duplicate connections are in the list.</p>
  
  <p>In this example: the connections occur in the order</p>
  
  <pre><code>dup = 0
  
  1-2
  
  1-2-3
  </code></pre>
  
  <p>then <code>[2,3]</code> are already connected so we increment <code>dup</code> by 1</p>
  
  <pre><code>1-2-3, 4-5
  
  1-2-3, 4-5-6
  </code></pre>
  
  <p>then <code>[5,6]</code> are already connected so again we increment <code>dup</code> by 1</p>
  
  <pre><code>1-2-3, 4-5-6, 10-11
  
  1-2-3, 4-5-6, 9-12, 10-11
  
  1-2-3, 4-5-6, 9-10-11-12 
  </code></pre>
  
  <p>return <code>dup = 2</code></p>
  
  <p>The last step is where my method messes up , because it counts <code>[12,10]</code> as a duplicate, since my current method is to add the numbers into a dictionary and check if both x and y are in the dictionary then i increment dup by 1</p>
  
  <p>But what I really need to do is check if x and y are already connected, and if they are then increment dup by 1</p>
  
  <p>But I am stuck trying to find a way to do this.</p>