Построены графики
This commit is contained in:
parent
ec3d83df97
commit
65e95f876b
|
|
@ -72,7 +72,6 @@ def ll_delete(head, name):
|
||||||
return head
|
return head
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ll_list_all(head):
|
def ll_list_all(head):
|
||||||
|
|
||||||
""" собирает все записи в список и сортирует (сортировка вынесена отдельно) """
|
""" собирает все записи в список и сортирует (сортировка вынесена отдельно) """
|
||||||
|
|
@ -130,7 +129,6 @@ def ht_insert(buckets, name, phone):
|
||||||
buckets[index] = ll_insert(buckets[index], name, phone)
|
buckets[index] = ll_insert(buckets[index], name, phone)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ht_find(buckets, name):
|
def ht_find(buckets, name):
|
||||||
""" """
|
""" """
|
||||||
idx = hash_func(name, len(buckets))
|
idx = hash_func(name, len(buckets))
|
||||||
|
|
|
||||||
4352
ProninVV/aufgabe-1-data-structures/graphics/Tre1.eps
Normal file
4352
ProninVV/aufgabe-1-data-structures/graphics/Tre1.eps
Normal file
File diff suppressed because it is too large
Load Diff
5139
ProninVV/aufgabe-1-data-structures/graphics/Tree.eps
Normal file
5139
ProninVV/aufgabe-1-data-structures/graphics/Tree.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ProninVV/aufgabe-1-data-structures/graphics/Tree.png
Normal file
BIN
ProninVV/aufgabe-1-data-structures/graphics/Tree.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
BIN
ProninVV/aufgabe-1-data-structures/graphics/Tree1.png
Normal file
BIN
ProninVV/aufgabe-1-data-structures/graphics/Tree1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
4407
ProninVV/aufgabe-1-data-structures/graphics/hasht.eps
Normal file
4407
ProninVV/aufgabe-1-data-structures/graphics/hasht.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ProninVV/aufgabe-1-data-structures/graphics/hasht.png
Normal file
BIN
ProninVV/aufgabe-1-data-structures/graphics/hasht.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
5082
ProninVV/aufgabe-1-data-structures/graphics/llist.eps
Normal file
5082
ProninVV/aufgabe-1-data-structures/graphics/llist.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ProninVV/aufgabe-1-data-structures/graphics/llist.png
Normal file
BIN
ProninVV/aufgabe-1-data-structures/graphics/llist.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
4329
ProninVV/aufgabe-1-data-structures/graphics/llist2.eps
Normal file
4329
ProninVV/aufgabe-1-data-structures/graphics/llist2.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
ProninVV/aufgabe-1-data-structures/graphics/llist2.png
Normal file
BIN
ProninVV/aufgabe-1-data-structures/graphics/llist2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
|
|
@ -10,54 +10,122 @@ from scipy.optimize import curve_fit
|
||||||
from numpy.polynomial import Polynomial
|
from numpy.polynomial import Polynomial
|
||||||
|
|
||||||
|
|
||||||
folder_path = 'results'
|
# folder_path = 'results'
|
||||||
|
|
||||||
# 2. Список размеров (500, 1000, 2000, 5000, 10000)
|
# # Список размеров (500, 1000, 2000, 5000, 10000)
|
||||||
sizes = ['500', '1000', '2000', '5000', '10000']
|
# sizes = ['500', '1000', '2000', '5000', '10000']
|
||||||
|
|
||||||
for size in sizes:
|
# for size in sizes:
|
||||||
files = glob.glob(os.path.join(folder_path, f'timedata_{size}_epochs_*.csv'))
|
# files = glob.glob(os.path.join(folder_path, f'timedata_{size}_epochs_*.csv'))
|
||||||
|
|
||||||
if not files:
|
# if not files:
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
# Читаем файлы
|
# # Читаем файлы
|
||||||
dfs = [pd.read_csv(f) for f in files]
|
# dfs = [pd.read_csv(f) for f in files]
|
||||||
|
|
||||||
# 1. Определяем, какие колонки текстовые (не числовые)
|
# # Определяем, какие колонки текстовые (не числовые)
|
||||||
# Предполагаем, что во всех файлах они одинаковые
|
# # Предполагаем, что во всех файлах они одинаковые
|
||||||
text_cols = dfs[0].select_dtypes(exclude=['number']).columns.tolist()
|
# text_cols = dfs[0].select_dtypes(exclude=['number']).columns.tolist()
|
||||||
|
|
||||||
# 2. Объединяем и считаем среднее
|
# # Объединяем и считаем среднее
|
||||||
# Группируем по текстовым колонкам, чтобы они остались в результате
|
# # Группируем по текстовым колонкам, чтобы они остались в результате
|
||||||
if text_cols:
|
# if text_cols:
|
||||||
combined = pd.concat(dfs)
|
# combined = pd.concat(dfs)
|
||||||
mean_df = combined.groupby(text_cols).mean().reset_index()
|
# mean_df = combined.groupby(text_cols).mean().reset_index()
|
||||||
else:
|
# else:
|
||||||
# Если текста нет, просто среднее по строкам
|
# # Если текста нет, просто среднее по строкам
|
||||||
mean_df = pd.concat(dfs).groupby(level=0).mean()
|
# mean_df = pd.concat(dfs).groupby(level=0).mean()
|
||||||
|
|
||||||
|
|
||||||
output_name = f'average_timedata_{size}.csv'
|
# output_name = f'average_timedata_{size}.csv'
|
||||||
mean_df.to_csv(os.path.join(folder_path, output_name), index=False)
|
# mean_df.to_csv(os.path.join(folder_path, output_name), index=False)
|
||||||
print(f"Файл {output_name} успешно создан")
|
# print(f"Файл {output_name} успешно создан")
|
||||||
|
|
||||||
|
|
||||||
|
df500 = pd.read_csv("results/average_timedata_500.csv")
|
||||||
|
df1000 = pd.read_csv("results/average_timedata_1000.csv")
|
||||||
|
df2000 = pd.read_csv("results/average_timedata_2000.csv")
|
||||||
|
df5000 = pd.read_csv("results/average_timedata_5000.csv")
|
||||||
|
df10000 = pd.read_csv("results/average_timedata_10000.csv")
|
||||||
|
|
||||||
|
|
||||||
|
def select_data_list(ax):
|
||||||
|
dfs = [df500, df1000, df2000, df5000, df10000]
|
||||||
|
Nvals = [500, 1000, 2000, 5000, 10000]
|
||||||
|
# delete, find, insert
|
||||||
|
# список:
|
||||||
|
valsSort = [list(arr[(arr['Структура'] == "linklist") & (arr['Режим'] == "sorted")]["Время (сек)"]) for arr in dfs]
|
||||||
|
valsShuff = [list(arr[(arr['Структура'] == "linklist") & (arr['Режим'] == "shuffled")]["Время (сек)"]) for arr in dfs]
|
||||||
|
# 0 - sorted 1 - shuffled
|
||||||
|
# delete
|
||||||
|
ax[0].plot(Nvals, [row[0] for row in valsSort], label="delete", color='red')
|
||||||
|
ax[1].plot(Nvals, [row[0] for row in valsShuff], color='red')
|
||||||
|
# find
|
||||||
|
ax[0].plot(Nvals, [row[1] for row in valsSort], label="find", color='blue')
|
||||||
|
ax[1].plot(Nvals, [row[1] for row in valsShuff], color='blue')
|
||||||
|
# insert
|
||||||
|
ax[0].plot(Nvals, [row[2] for row in valsSort], label="insert", color='green')
|
||||||
|
ax[1].plot(Nvals, [row[2] for row in valsShuff], color='green')
|
||||||
|
|
||||||
|
|
||||||
|
def select_data_hasht(ax):
|
||||||
|
dfs = [df500, df1000, df2000, df5000, df10000]
|
||||||
|
Nvals = [500, 1000, 2000, 5000, 10000]
|
||||||
|
# delete, find, insert
|
||||||
|
# список:
|
||||||
|
valsSort = [list(arr[(arr['Структура'] == "hashtable") & (arr['Режим'] == "sorted")]["Время (сек)"]) for arr in dfs]
|
||||||
|
valsShuff = [list(arr[(arr['Структура'] == "hashtable") & (arr['Режим'] == "shuffled")]["Время (сек)"]) for arr in dfs]
|
||||||
|
# 0 - sorted 1 - shuffled
|
||||||
|
# delete
|
||||||
|
ax[0].plot(Nvals, [row[0] for row in valsSort], label="delete", color='red')
|
||||||
|
ax[1].plot(Nvals, [row[0] for row in valsShuff], color='red')
|
||||||
|
# find
|
||||||
|
ax[0].plot(Nvals, [row[1] for row in valsSort], label="find", color='blue')
|
||||||
|
ax[1].plot(Nvals, [row[1] for row in valsShuff], color='blue')
|
||||||
|
# insert
|
||||||
|
ax[0].plot(Nvals, [row[2] for row in valsSort], label="insert", color='green')
|
||||||
|
ax[1].plot(Nvals, [row[2] for row in valsShuff], color='green')
|
||||||
|
|
||||||
|
|
||||||
|
def select_data_tree(ax):
|
||||||
|
dfs = [df500, df1000, df2000, df5000, df10000]
|
||||||
|
Nvals = [500, 1000, 2000, 5000, 10000]
|
||||||
|
# delete, find, insert
|
||||||
|
# список:
|
||||||
|
valsSort = [list(arr[(arr['Структура'] == "bintree") & (arr['Режим'] == "sorted")]["Время (сек)"]) for arr in dfs]
|
||||||
|
valsShuff = [list(arr[(arr['Структура'] == "bintree") & (arr['Режим'] == "shuffled")]["Время (сек)"]) for arr in dfs]
|
||||||
|
# 0 - sorted 1 - shuffled
|
||||||
|
# delete
|
||||||
|
ax[0].plot(Nvals, [row[0] for row in valsSort], label="delete", color='red')
|
||||||
|
ax[1].plot(Nvals, [row[0] for row in valsShuff], color='red')
|
||||||
|
# find
|
||||||
|
ax[0].plot(Nvals, [row[1] for row in valsSort], label="find", color='blue')
|
||||||
|
ax[1].plot(Nvals, [row[1] for row in valsShuff], color='blue')
|
||||||
|
# insert
|
||||||
|
ax[0].plot(Nvals, [row[2] for row in valsSort], label="insert", color='green')
|
||||||
|
ax[1].plot(Nvals, [row[2] for row in valsShuff], color='green')
|
||||||
|
|
||||||
|
# list(df500[(df500['Структура'] == "linklist") & (df500['Режим'] == "shuffled")]["Время (сек)"])
|
||||||
|
|
||||||
# построение графика
|
# построение графика
|
||||||
# fig, ax = plt.subplots(figsize=(8, 5))
|
fig, ax = plt.subplots(figsize=(10, 5), nrows=1, ncols=2)
|
||||||
|
for i in range(2):
|
||||||
|
# select_data_list(ax)
|
||||||
|
# select_data_hasht(ax)
|
||||||
|
select_data_tree(ax)
|
||||||
|
ax[0].set_title("График сложностей для дерева (sort)")
|
||||||
|
ax[1].set_title("График сложностей для дерева (shuff)")
|
||||||
|
ax[i].set_xlabel("N")
|
||||||
|
ax[i].set_ylabel("сек * ")
|
||||||
|
ax[i].grid(which="major", linewidth=1.5)
|
||||||
|
ax[i].grid(which="minor", color="gray", linewidth=0.5)
|
||||||
|
ax[i].xaxis.set_minor_locator(AutoMinorLocator())
|
||||||
|
ax[i].yaxis.set_minor_locator(AutoMinorLocator())
|
||||||
|
ax[i].legend()
|
||||||
|
ax[i].set_ylim(0, 0.1)
|
||||||
|
plt.savefig('graphics\Tree1.png', dpi=200)
|
||||||
|
plt.savefig('graphics\Tre1.eps', dpi=200)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
# ax.set_title("График зависимости фазы от частоты(сх5)")
|
|
||||||
# ax.set_xlabel("v, Hz")
|
|
||||||
# ax.set_ylabel("phi, rad")
|
|
||||||
# ax.grid(which="major", linewidth=1.5)
|
|
||||||
# ax.grid(which="minor", color="gray", linewidth=0.5)
|
|
||||||
# ax.xaxis.set_minor_locator(AutoMinorLocator())
|
|
||||||
# ax.yaxis.set_minor_locator(AutoMinorLocator())
|
|
||||||
# ax.axhline(y=0, color='black', linewidth=1, linestyle='-', alpha=0.7) # Ось X (U=0)
|
|
||||||
# ax.axvline(x=0, color='black', linewidth=1, linestyle='-', alpha=0.7) # Ось Y (B=0)
|
|
||||||
# ax.plot(1, 0, ">k", transform=ax.get_yaxis_transform(), clip_on=False)
|
|
||||||
# ax.plot(0, 1, "^k", transform=ax.get_xaxis_transform(), clip_on=False)
|
|
||||||
# ax.legend()
|
|
||||||
# plt.savefig('graphics\zadanie3.png', dpi=200)
|
|
||||||
# plt.savefig('graphics\zadanie3.eps', dpi=200)
|
|
||||||
# plt.show()
|
|
||||||
|
|
@ -53,6 +53,8 @@
|
||||||
|
|
||||||
\section{Результаты и анализ}
|
\section{Результаты и анализ}
|
||||||
Было проведено 5 опытов.
|
Было проведено 5 опытов.
|
||||||
|
\subsection{Связный список}
|
||||||
|
|
||||||
|
|
||||||
\section{Заключение}
|
\section{Заключение}
|
||||||
% Ответ на вопрос о выборе структуры в реальной жизни
|
% Ответ на вопрос о выборе структуры в реальной жизни
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user