diff --git a/konnovaea/docs/data/graph_delete.png b/konnovaea/docs/data/graph_delete.png new file mode 100644 index 0000000..75a2633 Binary files /dev/null and b/konnovaea/docs/data/graph_delete.png differ diff --git a/konnovaea/docs/data/graph_insert.png b/konnovaea/docs/data/graph_insert.png new file mode 100644 index 0000000..77ed9b9 Binary files /dev/null and b/konnovaea/docs/data/graph_insert.png differ diff --git a/konnovaea/docs/data/graph_search.png b/konnovaea/docs/data/graph_search.png new file mode 100644 index 0000000..c55c4ab Binary files /dev/null and b/konnovaea/docs/data/graph_search.png differ diff --git a/konnovaea/docs/data/отчет.ipynb b/konnovaea/docs/data/отчет.ipynb new file mode 100644 index 0000000..e69de29 diff --git a/konnovaea/make_graphs.py b/konnovaea/make_graphs.py new file mode 100644 index 0000000..99312f6 --- /dev/null +++ b/konnovaea/make_graphs.py @@ -0,0 +1,126 @@ + +import matplotlib.pyplot as plt +import numpy as np +import os + + +os.makedirs('docs/data', exist_ok=True) + + +structures = ['LinkedList', 'HashTable', 'BST'] + +# Вставка 10000 записей +random_insert = [0.0037545, 0.015088, 0.026280] +sorted_insert = [0.0017544, 0.011369, 4.930788] + +# Поиск 110 записей +random_search = [0.00000962, 0.0001646, 0.0002592] +sorted_search = [0.00000858, 0.00014016, 0.047126] + +# Удаление 50 записей +random_delete = [0.0000079, 0.00009824, 0.00016984] +sorted_delete = [0.00000294, 0.00005878, 0.023013] + +x = np.arange(len(structures)) +width = 0.35 + +#график вставка +fig, ax = plt.subplots(figsize=(12, 7)) + +bars1 = ax.bar(x - width/2, random_insert, width, label='Случайный порядок', color='#3498db') +bars2 = ax.bar(x + width/2, sorted_insert, width, label='Отсортированный порядок', color='#e74c3c') + + +for bar in bars1: + height = bar.get_height() + ax.annotate(f'{height:.4f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + +for bar in bars2: + height = bar.get_height() + if height < 1: + ax.annotate(f'{height:.4f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + else: + ax.annotate(f'{height:.1f} сек', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 5), textcoords="offset points", ha='center', va='bottom', fontsize=10, fontweight='bold') + +ax.set_ylabel('Время (сек)', fontsize=12) +ax.set_title('Время вставки 10000 записей', fontsize=14, fontweight='bold') +ax.set_xticks(x) +ax.set_xticklabels(structures, fontsize=11) +ax.legend(fontsize=11) +ax.set_yscale('log') +ax.grid(True, alpha=0.3, axis='y') + +plt.tight_layout() +plt.savefig('docs/data/graph_insert.png', dpi=150, bbox_inches='tight') +plt.close() +print(" График 1 сохранён: docs/data/graph_insert.png") + +# график поиск +fig, ax = plt.subplots(figsize=(12, 7)) + +bars1 = ax.bar(x - width/2, random_search, width, label='Случайный порядок', color='#3498db') +bars2 = ax.bar(x + width/2, sorted_search, width, label='Отсортированный порядок', color='#e74c3c') + +for bar in bars1: + height = bar.get_height() + ax.annotate(f'{height:.6f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + +for bar in bars2: + height = bar.get_height() + if height < 0.01: + ax.annotate(f'{height:.6f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + else: + ax.annotate(f'{height:.4f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + +ax.set_ylabel('Время (сек)', fontsize=12) +ax.set_title('Время поиска 110 записей', fontsize=14, fontweight='bold') +ax.set_xticks(x) +ax.set_xticklabels(structures, fontsize=11) +ax.legend(fontsize=11) +ax.set_yscale('log') +ax.grid(True, alpha=0.3, axis='y') + +plt.tight_layout() +plt.savefig('docs/data/graph_search.png', dpi=150, bbox_inches='tight') +plt.close() +print(" График 2 сохранён: docs/data/graph_search.png") + +# график удаление +fig, ax = plt.subplots(figsize=(12, 7)) + +bars1 = ax.bar(x - width/2, random_delete, width, label='Случайный порядок', color='#3498db') +bars2 = ax.bar(x + width/2, sorted_delete, width, label='Отсортированный порядок', color='#e74c3c') + +for bar in bars1: + height = bar.get_height() + ax.annotate(f'{height:.6f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + +for bar in bars2: + height = bar.get_height() + if height < 0.01: + ax.annotate(f'{height:.6f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + else: + ax.annotate(f'{height:.4f}', xy=(bar.get_x() + bar.get_width()/2, height), + xytext=(0, 3), textcoords="offset points", ha='center', va='bottom', fontsize=9) + +ax.set_ylabel('Время (сек)', fontsize=12) +ax.set_title('Время удаления 50 записей', fontsize=14, fontweight='bold') +ax.set_xticks(x) +ax.set_xticklabels(structures, fontsize=11) +ax.legend(fontsize=11) +ax.set_yscale('log') +ax.grid(True, alpha=0.3, axis='y') + +plt.tight_layout() +plt.savefig('docs/data/graph_delete.png', dpi=150, bbox_inches='tight') +plt.close() +print(" График 3 сохранён: docs/data/graph_delete.png") +