Passing Functions
John Nagle
nagle at animats.com
Fri Mar 11 12:15:04 EST 2011
On 3/11/2011 5:49 AM, yoro wrote:
> I've found the error, I had to type in:
>
> for node in nodeTable:
> if node != 0 and Node.visited == False:
That's just your first error.
(Also, you shouldn't have anything but Node items in
nodeTable, so you don't need the "node != 0".)
The biggest problem is at
#Values to assign to each node
> > class Node:
> > distFromSource = infinity
> > previous = invalid_node
> > visited = False
Those are variables of the entire class. Every
instance of Node shares the same variables. You
need
class Node:
def __init__(self) :
self.distFromSource = infinity
self.previous = invalid_node
self.visited = False
John Nagle
More information about the Python-list
mailing list