Hello,
I have some code that passes arguments between functions, though I am failing to understand why my code isn't working. This is the relevant section of my Dijkstra's algorithm code:
def network():
f = open ('network.txt', 'r')
network = [[int(node) for node in line.split(',')] for line in f.readlines()]
print network
return network
The above function reads in the distances between the nodes from a text file, which is hoped would then be able to be read in to the function below which finds the nearest neighbour of each node:
#find the nearest neighbour to a particular node
def nearestNeighbour(currentNode, network):
nearestNeighbour = []
nodeIndex = 0
for node in network[currentNode]:
#for node in network[currentNode]:
if node != 0 & currentNode.visited == false:
nearestNeighbour.append(nodeIndex)
nodeIndex +=1
return nearestNeighbour
However, I am getting this error message:
for node in network:
TypeError: 'function' object is not iterable
Any thoughts would be greatly appreciated