Loading diagrammes/.~lock.algoDePlacement.odt# 0 → 100644 +1 −0 Original line number Diff line number Diff line ,LAPTOP-GJS36RRU/aurel,LAPTOP-GJS36RRU,02.06.2022 21:50,file:///C:/Users/aurel/AppData/Roaming/LibreOffice/4; No newline at end of file model/levelEnum.py +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ def getTreePlanarTreeToBinaryTree(level): elif level == 3: return LevelsPlanarTreeToBinaryTree.Lvl3.value else: return Tree(randomTree(level + 1)) return Tree(randomTree(10)) def getTreeBinaryTreeToPlanarTree(level): if level == 1: Loading model/node.py +9 −3 Original line number Diff line number Diff line Loading @@ -766,22 +766,27 @@ class EmptyNode(Node): return ' ' * tab + 'EMPTY' + '\n' def randomTree(nbNodes): def randomTree(nbInternNodes): """ This method generate a random binary tree with the number of intern nodes nbNodes :param nbNodes: the number of intern nodes of the tree the method will create :param nbInternNodes: the number of intern nodes of the tree the method will create :return: a random binary tree """ n = BinaryNode(Leaf(), Leaf()) nodeList = [n, n.left, n.right] nbNodeTotal = 2 root = 0 for i in range(nbNodes - 1): for i in range(nbInternNodes - 1): # we randomly choose a node in the current tree, we will place a new node at its place # and the chosen node will become one of the children of this new node nodeIndex = randint(0, nbNodeTotal) chosenNode = nodeList[nodeIndex] if root != nodeIndex: parent = chosenNode.parent # we randomly choose a side: left or right # if we choose right, we will place the choosen node as the right child of the new node and at left, we will # place a leaf and vice versa if randint(0, 1) == 0: n = BinaryNode(chosenNode, Leaf()) nodeList.append(n) Loading @@ -790,6 +795,7 @@ def randomTree(nbNodes): n = BinaryNode(Leaf(), chosenNode) nodeList.append(n) nodeList.append(n.left) # we place the new node as the child of the former parent of the node we chose at beginning if root != nodeIndex: parent[0].changeChild(nodeList[nbNodeTotal + 1], parent[1]) else: Loading Loading
diagrammes/.~lock.algoDePlacement.odt# 0 → 100644 +1 −0 Original line number Diff line number Diff line ,LAPTOP-GJS36RRU/aurel,LAPTOP-GJS36RRU,02.06.2022 21:50,file:///C:/Users/aurel/AppData/Roaming/LibreOffice/4; No newline at end of file
model/levelEnum.py +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ def getTreePlanarTreeToBinaryTree(level): elif level == 3: return LevelsPlanarTreeToBinaryTree.Lvl3.value else: return Tree(randomTree(level + 1)) return Tree(randomTree(10)) def getTreeBinaryTreeToPlanarTree(level): if level == 1: Loading
model/node.py +9 −3 Original line number Diff line number Diff line Loading @@ -766,22 +766,27 @@ class EmptyNode(Node): return ' ' * tab + 'EMPTY' + '\n' def randomTree(nbNodes): def randomTree(nbInternNodes): """ This method generate a random binary tree with the number of intern nodes nbNodes :param nbNodes: the number of intern nodes of the tree the method will create :param nbInternNodes: the number of intern nodes of the tree the method will create :return: a random binary tree """ n = BinaryNode(Leaf(), Leaf()) nodeList = [n, n.left, n.right] nbNodeTotal = 2 root = 0 for i in range(nbNodes - 1): for i in range(nbInternNodes - 1): # we randomly choose a node in the current tree, we will place a new node at its place # and the chosen node will become one of the children of this new node nodeIndex = randint(0, nbNodeTotal) chosenNode = nodeList[nodeIndex] if root != nodeIndex: parent = chosenNode.parent # we randomly choose a side: left or right # if we choose right, we will place the choosen node as the right child of the new node and at left, we will # place a leaf and vice versa if randint(0, 1) == 0: n = BinaryNode(chosenNode, Leaf()) nodeList.append(n) Loading @@ -790,6 +795,7 @@ def randomTree(nbNodes): n = BinaryNode(Leaf(), chosenNode) nodeList.append(n) nodeList.append(n.left) # we place the new node as the child of the former parent of the node we chose at beginning if root != nodeIndex: parent[0].changeChild(nodeList[nbNodeTotal + 1], parent[1]) else: Loading