57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
#Графики
|
|
import csv
|
|
import matplotlib.pyplot as plt
|
|
|
|
data = []
|
|
|
|
with open('results.csv', 'r') as f:
|
|
reader = csv.reader(f)
|
|
for row in reader:
|
|
data.append(row)
|
|
|
|
print(data)
|
|
|
|
types = ["shuffled","sorted"]
|
|
algorythms = ['Linked list','Hash-table','BST']
|
|
operations = ['Insert','Find','Delete']
|
|
for dt in types:
|
|
|
|
for ot in operations:
|
|
|
|
X = algorythms
|
|
Y = [0.,0.,0.]
|
|
|
|
for row in data:
|
|
if row[1] == dt and row[2] == ot:
|
|
if row[0] == X[0]:
|
|
Y[0] = float(row[3])
|
|
elif row[0] == X[1]:
|
|
Y[1] = float(row[3])
|
|
elif row[0] == X[2]:
|
|
Y[2] = float(row[3])
|
|
|
|
plt.bar(X,Y)
|
|
plt.title(dt + ot)
|
|
plt.ylabel('Время')
|
|
plt.show()
|
|
|
|
for dt in types:
|
|
|
|
for at in algorythms:
|
|
|
|
X = operations
|
|
Y = [0.,0.,0.]
|
|
|
|
for row in data:
|
|
if row[1] == dt and row[0] == at:
|
|
if row[2] == X[0]:
|
|
Y[0] = float(row[3])
|
|
elif row[2] == X[1]:
|
|
Y[1] = float(row[3])
|
|
elif row[2] == X[2]:
|
|
Y[2] = float(row[3])
|
|
|
|
plt.bar(X,Y,color='g')
|
|
plt.title(dt + at)
|
|
plt.ylabel('Время')
|
|
plt.show() |