The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000
The previous node is -1
The distance from source is 1000000

How can I post the rest of my code without causing confusion for other people?
–
user612041Mar 13 '11 at 17:48

You can try to edit your code and make it more concise, by that I mean it should contain at least descriptions of what each variable types are. Typically with more context, people can help you better. The second step is to just try to provide more details when asked :-)
–
Ke SunMar 13 '11 at 17:51

So what does print(theNetWork) tell you? If you see it's something like: [[1,3],[4,5],...,] then that's the problem. You want theNetwork to be a list of integers, such as [1,2,3,4], so you can use it's values as index to access the other list.
–
Ke SunMar 13 '11 at 18:07

1

I would check @phihag's answer, and if that doesn't help you will need to rethink the way you want to access listOfNeighbours values. Basically right now theNetwork is a list of lists, you can't use a list as an index to another array.
–
Ke SunMar 13 '11 at 18:19

listOfNeighbors is a list, indexed from zero. So, listOfNeighbors[0] = 2, listOfNeighbors[1] = 4. The error is telling you that nodeIndex, which you're using as indices to access the items in listOfNeighbors, is a list -- not an integer value as expected. Which means that theNetwork must be comprised of lists. You can try a "print nodeIndex" prior to assigning a value to currentDistance to see what it's comprised of. Also, I don't see where you define "node" or "indexNode" in the above function, either.

Also, just to clarify -- is this a function you will ultimately pass to map? I don't see a map call anywhere in the function.

I've typed in 'print nodeIndex' above 'currentDistance =' but says that the global name 'node index' is not defined. The intention is to look at the list of neighbours, which should be comprised of ints, and work out the distance from source, and I think map is best used for this as it's a list at the moment
–
user612041Mar 13 '11 at 18:04

@user612041: If you typed print nodeIndex, the error message would NOT complain about node index. Try typing the correct name, and report back exactly what happened -- use copy/paste, don't type from memory. You don't have a problem with the map function, you haven't even used it, so don't include it in your question title.
–
John MachinMar 13 '11 at 20:02