Is there a way to neatly create large (i.e. indexable) empty lists in python?
This is what I am doing at the moment:
firstgen=G.neighbors(node1)
secgen=[]
thirdgen=[[],[],[],[],[],[],[],[],[],[],[]] #11 brackets because len(secgen)=11
for i in firstgen:
secgen.append(G.neighbors(i))
for i in range(len(secgen)):
for j in secgen[i]:
thirdgen[i].append(G.neighbors(j))
What I am doing is finding the neighbors of the neighbors of the neighbors of an original node in a network and so my third generation list of neighbors should have the structure [ [[...],[...],[...]] , [[...],[...],[...]] , [[...],[...],[...]] ] but I am new to python and have not been able to find how to make this work without manually putting in the length of thirdgen.
Sorry for the confusing explanation. I am doing this in order to find triads in the network i.e. if any of the third gen nodes are the same as the initial node then I have found a triad.
Thanks!
EDIT: I just realised that I can simply put thirdgen.append([]) in the first loop. Still curious about other methods though.