Adjacency List Implementation in Python
<p>I'm a newbie to Python (and computer science in general), so bear with me.</p>

<p>I'm having trouble implementing an adjacency list in Python. I have learned how to implement it through a dictionary (I learned how through here lol), but I need to know how to do it using only basic lists (list of lists)</p>

<p>This is my code:</p>

<pre><code>with open("graph1.txt") as infile:
    vertices = []
    for line in infile:
        line = line.split()
        line = [int(i) for i in line]
        vertices.append(line)


adj = dict()

for edge in vertices:
    x, y = int(edge[0]), int(edge[1])
    if x not in adj: adj[x] = set()
    if y not in adj: adj[y] = set()
    adj[x].add(y)
    adj[y].add(x)
print(adj)
</code></pre>

<p>Any help is appreciated.
Cheers</p>