http://imgur.com/a/Ijcbi
I've been trying to understand why it gives output like that,i know those are the vertices that connects but i just don't know how the table of [[1, 2], [0, 2, 3], [1, 0], [1]] is produced.
n = int(input("Enter the number of vertices you want")) FileName = input("Please input name of file:") edgeFile = open(FileName) #empty adj.list adjList = n*[0] for i in range(n): adjList[i]=[] #adj.list for line in edgeFile: edgePoint = line.split() adjList[int(edgePoint[0])].append(int(edgePoint[1])) adjList[int(edgePoint[1])].append(int(edgePoint[0])) edgeFile.close print(adjList)This code was given by lecturer and it works and gives the result : [[1, 2], [0, 2, 3], [1, 0], [1]]
I've been trying to understand why it gives output like that,i know those are the vertices that connects but i just don't know how the table of [[1, 2], [0, 2, 3], [1, 0], [1]] is produced.
Moderator Larz60+: Added code tags. Please use in the future