title: graph in python from a list of edges
body: <p>I have a list of edges in a text file:</p>
  
  <pre><code>0 1
  0 2
  0 3
  1 637
  1 754
  1 1319 
  1 1350
  1 1463
  1 1523
  2 637
  2 754
  2 1319
  2 1350
  2 1463
  2 1523
  3 499
  3 539
  3 595
  3 637
  3 706
  3 1128
  3 1194
  3 1213
  3 1319
  .. ...
  </code></pre>
  
  <p>I need to turn it into a dictionary like this:</p>
  
  <pre><code>graph = { "a" : ["c"],
        "b" : ["c", "e"],
        "c" : ["a", "b", "d", "e"],
        "d" : ["c"],
        "e" : ["c", "b"],
        "f" : []
      }
  </code></pre>
  
  <p>my attempt so far has been:</p>
  
  <pre><code>import numpy as np
  file_name='/Volumes/City_University/data_mining/Ecoli.txt'
  key_column=0
  
  dat=np.genfromtxt(file_name,dtype=str)
  d={i:[] for i in np.unique(dat[:,key_column])}
  
  for row in dat:
      for key in d.keys():
          if row[key_column]==key :d[key].append(row[1])
  
  print (d)
  </code></pre>
  
  <p>However, this does not work properly inasmuch i don't get a new key when this appear in the values: as an example
  I get:</p>
  
  <pre><code>'0': ["1", "2", "3"]
  '1': ['637', '754', '1319', '1350', '1463', '1523']
  </code></pre>
  
  <p>in the '1', the "0" is missing.</p>
  
  <p>to make it more simple. If I have a text like this</p>
  
  <pre><code>a b
  c d
  </code></pre>
  
  <p>I should get an outcome like:
  graph = { "a": ["b"], "b": ["a"], "c": ["d"], "d": ["c"]}</p>
  
  <p>thank you in advance</p>