diff --git a/src/ArbreB/Graph.gv b/src/ArbreB/Graph.gv index a6dc586c47baf840b5f9cf1aff8733073f64703d..fbd621aac8807411d3cc3fa04dcd693958127938 100644 --- a/src/ArbreB/Graph.gv +++ b/src/ArbreB/Graph.gv @@ -33,15 +33,12 @@ graph { "[22, 30]" "[14]" -- "[22, 30]" "[22, 30]" - "[18]" - "[22, 30]" -- "[18]" - "[18]" - "[16]" - "[18]" -- "[16]" - "[16]" - "[20]" - "[18]" -- "[20]" - "[20]" + "[]" + "[22, 30]" -- "[]" + "[]" + "[16, 18]" + "[]" -- "[16, 18]" + "[16, 18]" "[26]" "[22, 30]" -- "[26]" "[26]" diff --git a/src/ArbreB/Graph.gv.jpg b/src/ArbreB/Graph.gv.jpg index 820cb6a0f225e9920aa9e8cd467e450b32131b11..01fce48d9be8158ad91e1058c1f45250a1496e37 100644 Binary files a/src/ArbreB/Graph.gv.jpg and b/src/ArbreB/Graph.gv.jpg differ diff --git a/src/ArbreB/Graph.gv.pdf b/src/ArbreB/Graph.gv.pdf new file mode 100644 index 0000000000000000000000000000000000000000..c30e111e89c95f09e322d43d73319fce6e08f297 Binary files /dev/null and b/src/ArbreB/Graph.gv.pdf differ diff --git a/src/ArbreB/Graph2.gv.jpg b/src/ArbreB/Graph2.gv.jpg new file mode 100644 index 0000000000000000000000000000000000000000..820cb6a0f225e9920aa9e8cd467e450b32131b11 Binary files /dev/null and b/src/ArbreB/Graph2.gv.jpg differ diff --git a/src/BTree.py b/src/BTree.py index fa1b3bf76149edc72f90a95472a2523d1a59e989..e7dd336438327ba442855fdb5d7bd912a0c2b7e3 100644 --- a/src/BTree.py +++ b/src/BTree.py @@ -101,6 +101,25 @@ class Btree() : """ (ok, _, _, _) = self.root.is_ArbreB(self.k, True) return ok + + def suppr(self, value, k): + """ + Supprimer une valeur dans l'arbre + Params : + value : (int), valeur à supprimer + k : (int), nombre de clés + + Return : + #TODO + Exemple(s): + >>> arbreB = Btree(2, Node([5,25])) + >>> arbreB.suppr(25,2) + True + >>> arbreB + Btree(Node([5])) + + """ + return self.root.suppression(value, k, True) def __repr__(self) : """ diff --git a/src/experimentation.py b/src/experimentation.py index 0d65c57b2c6780b2be885b49eca6279819538596..c5998c2c4134d6636dfbc39d78fe1b22511e5eab 100644 --- a/src/experimentation.py +++ b/src/experimentation.py @@ -7,67 +7,48 @@ from BTree import Btree class experimentation: def __init__(self, exp): - self.btree = Btree(2, Node([])) if exp == "1": self.experimentationInsert1() - elif "2": + elif exp == "2": self.experimentationSuppr1() - else : - None + elif exp == "3" : + self.experimentationInsert2() - def experimentationInsert1(self): + def experimentationInsert1(self): + self.btree = Btree(2, Node([])) for n in [2, 4, 5] + list(range(6, 37, 2)) + [7, 9, 11, 13]: self.btree.insertion(n) + Visualization(self.btree).render() - + print("est un arbreB : " + str(self.btree.isBalance())) print(self.btree) def experimentationSuppr1(self): + self.btree = Btree(2, Node([])) + #non fonctionnel + print("Non fonctionnel") for n in [2, 4, 5] + list(range(6, 37, 2)) + [7, 9, 11, 13]: self.btree.insertion(n) + self.btree.suppr(20,2) + Visualization(self.btree).render() #for n in [14,10,20,18,16,24,6] + + print(self.btree) + + def experimentationInsert2(self): + self.btree = Btree(10, Node([])) + for n in list(range(100000)): + self.btree.insertion(n) + + #Visualization(self.btree).render() + print("est un arbreB : " + str(self.btree.isBalance())) + print(self.btree) - - - -# fonction temporaire pour tester la correspondance des arbres de manière automatique et simple visuellement -# def isCorrect(self, BTreeTest): -# if (self.btree.equals(BTreeTest)): -# print("Correct") -# else: -# print("error") - - - - - - - - - - - - if __name__ == "__main__": - response = input("Quelle expérimentation voulez vous (1 ou 2)") - experiment = experimentation(response) - - - - - - -# if __name__ == "__main__": -# import sys -# sys.path.insert(1, './src') -# sys.path.insert(2, '../src') -# from Node import * -# -# unittest.main() -# import doctest -# doctest.testmod(verbose=False) \ No newline at end of file + response = input("Quelle expérimentation voulez vous (1: insertion1 / 2: suppression1 / 3: insertion3 )") + experiment = experimentation(response) \ No newline at end of file