Re: possibilità nei librogame |
Oggetto: Re: possibilità nei librogame inviato da toki il 1/7/2008 14:14:13 class Node: def __init__(self,key): self.key = key self.children = [] def visit(root,curPath,paths): if root.children == []: paths += [curPath] for x in root.children: visit(x,curPath + [x.key],paths) # ******************************************************************** # Test # ******************************************************************** root = Node("a") v1 = Node("b") v2 = Node("c") v3 = Node("d") v4 = Node("e") v5 = Node("f") v6 = Node("g") root.children += [v1] root.children += [v2] v1.children += [v3] v1.children += [v4] v2.children += [v5] v2.children += [v6] paths = [] visit(root,[root.key],paths) print paths |