title: Removing duplicate edges from graph in Python list
body: <p>My program returns a list of tuples, which represent the edges of a graph, in the form of:</p>
  
  <pre><code>[(i, (e, 130)), (e, (i, 130)), (g, (a, 65)), (g, (d, 15)), (a, (g, 65))]
  </code></pre>
  
  <p>So, (i, (e, 130)) means that 'i' is connected to 'e' and is 130 units away.</p>
  
  <p>Similarly, (e, (i, 130)) means that 'e' is connected to 'i' and is 130 units away.
  So essentially, both these tuples represent the same thing.</p>
  
  <p>How would I remove any one of them from this list?
  Desired output:</p>
  
  <pre><code>[(i, (e, 130)), (g, (a, 65)), (g, (d, 15))]
  </code></pre>
  
  <p>I tried writing an equals function. Would this be of any help?</p>
  
  <pre><code>def edge_equal(edge_tuple1, edge_tuple2):
      return edge_tuple1[0] == edge_tuple2[1][0] and edge_tuple2[0] == edge_tuple1[1][0]
  </code></pre>