Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import os
- import matplotlib.pyplot as plt
- maior_sub = []
- prob = ['0.01/', '0.110000/', '0.210000/', '0.310000/', '0.410000/', '0.510000/', '0.610000/', '0.710000/', '0.810000/', '0.910000/']
- def format_n(string):
- aux_str = ""
- for i in range(len(string)):
- if i > 4 and i < (len(string) - 4):
- aux_str += string[i]
- return aux_str
- def format_prob(string):
- return string[:-1]
- def sort_prob(dic):
- new_dic = {}
- for key, value in sorted(dic.items()):
- print(key, value)
- new_dic.update({key: value})
- return new_dic
- def main():
- for j in range(10):
- dir = "/home/tiago/Desktop/MEI/Assigment1/data/output1/bubble/"+prob[j]
- arr = sorted(os.listdir(dir))
- print(">>> prob: " + str(format_prob(prob[j])))
- plot_x = []
- plot_y = []
- prob_dic = {}
- for i in range(10):
- file = dir + arr[i]
- with open(file) as csv_file:
- line = 0
- data = csv.reader(csv_file)
- for row in data:
- line += 1
- if line == 4:
- #print("N: " + str(format_n(arr[i])))
- #print(row)
- prob_dic.update({int(format_n(arr[i])): int(row[0])})
- prob_dic = sort_prob(prob_dic)
- #print(prob_dic)
- print(prob_dic.keys())
- print(prob_dic.values())
- plt.plot(prob_dic.keys(), prob_dic.values())
- plt.title("Gráfico de sub-sequencia maior com prob: " + str(format_prob(prob[j])))
- plt.show()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement