The file contains:
1 2
2 6
2 3
2 4
3 1
3 4
4 5
5 4
6 5
6 7
7 6
7 8
8 5
8 7
From that a dictionary has to be created as follows:
D = {1: [2], 2: [6,3,4], 3: [1,4], 4: [5], 5: [4], 6: [5,7], 7: [6,8], 8: [5,7]}
Where the first element from the line is the key. What is the most efficient way?