Loading model/node.py +36 −5 Changes for model/node.py: 36 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -330,6 +330,29 @@ class PlanarNode(Node): def changeChild(self, node, index: int): self.children[index] = node def numberNodes(self, index=0, brothers=None): if brothers is None: brothers = [] if not self.children: if brothers: brother = brothers.pop(0) print("A") print(brother) brother.numberNodes(index, brothers) else: newBrothers = self.children[1:] + brothers print("B") print(self.children[0]) self.children[0].numberNodes(index, newBrothers) def completeNode(self, index: int, nodeType: str, tree): print("---------------------") print(index) print(self) print("---------------------") for child in self.children: child.completeNode(index, nodeType, tree) def setup(self, depth=0, places=None, offsets=None): nb_children = len(self.children) if places is None: Loading Loading @@ -468,15 +491,21 @@ class IncompleteNode(PlanarNode): self.parent = (node, index) def numberNodes(self, index=0, brothers=None): print("bro:") print(brothers) if brothers is None: brothers = [] self.index = index if not self.children: if brothers: brothers[0].numberNodes(index + 1, brothers.pop(0)) brother = brothers.pop(0) print("A") print(brother) brother.numberNodes(index + 1, brothers) else: newBrothers = self.children[1:] + brothers print("B") print(self.children[0]) self.children[0].numberNodes(index + 1, newBrothers) def completeNode(self, index: int, nodeType: str, tree): Loading Loading @@ -822,16 +851,18 @@ if __name__ == '__main__': ptroot = binaryTreeToPlanarTree(btroot)""" ptroot = IncompleteNode([IncompleteNode([IncompleteNode([])]), """ptroot = IncompleteNode([IncompleteNode([IncompleteNode([])]), IncompleteNode([IncompleteNode([]), IncompleteNode([])]), IncompleteNode([IncompleteNode([]), IncompleteNode([]), IncompleteNode([])])]) print(ptroot) ptroot.numberNodes() print(ptroot) print(ptroot)""" """l1 = ["a","b"] c = "c" print(l1 + [c])""" c = l1[1:] print(c)""" """print(ptroot) btroot2 = planarTreeToBinaryTree(ptroot)""" Loading
model/node.py +36 −5 Changes for model/node.py: 36 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -330,6 +330,29 @@ class PlanarNode(Node): def changeChild(self, node, index: int): self.children[index] = node def numberNodes(self, index=0, brothers=None): if brothers is None: brothers = [] if not self.children: if brothers: brother = brothers.pop(0) print("A") print(brother) brother.numberNodes(index, brothers) else: newBrothers = self.children[1:] + brothers print("B") print(self.children[0]) self.children[0].numberNodes(index, newBrothers) def completeNode(self, index: int, nodeType: str, tree): print("---------------------") print(index) print(self) print("---------------------") for child in self.children: child.completeNode(index, nodeType, tree) def setup(self, depth=0, places=None, offsets=None): nb_children = len(self.children) if places is None: Loading Loading @@ -468,15 +491,21 @@ class IncompleteNode(PlanarNode): self.parent = (node, index) def numberNodes(self, index=0, brothers=None): print("bro:") print(brothers) if brothers is None: brothers = [] self.index = index if not self.children: if brothers: brothers[0].numberNodes(index + 1, brothers.pop(0)) brother = brothers.pop(0) print("A") print(brother) brother.numberNodes(index + 1, brothers) else: newBrothers = self.children[1:] + brothers print("B") print(self.children[0]) self.children[0].numberNodes(index + 1, newBrothers) def completeNode(self, index: int, nodeType: str, tree): Loading Loading @@ -822,16 +851,18 @@ if __name__ == '__main__': ptroot = binaryTreeToPlanarTree(btroot)""" ptroot = IncompleteNode([IncompleteNode([IncompleteNode([])]), """ptroot = IncompleteNode([IncompleteNode([IncompleteNode([])]), IncompleteNode([IncompleteNode([]), IncompleteNode([])]), IncompleteNode([IncompleteNode([]), IncompleteNode([]), IncompleteNode([])])]) print(ptroot) ptroot.numberNodes() print(ptroot) print(ptroot)""" """l1 = ["a","b"] c = "c" print(l1 + [c])""" c = l1[1:] print(c)""" """print(ptroot) btroot2 = planarTreeToBinaryTree(ptroot)"""