Minor fixes and changes

This commit is contained in:
Valentin Brandl 2022-04-07 19:35:43 +02:00
parent 725077750c
commit dc10f471cd
2 changed files with 12 additions and 5 deletions

View File

@ -28,7 +28,8 @@ def load_data(path):
return data
list_churned_peers = [20, 30, 40, 50, 60, 70, 80, 90, 100]
# list_churned_peers = [20, 30, 40, 50, 60, 70, 80, 90, 100]
list_churned_peers = [3, 5, 10]
iterations = 5
def main():
# random but reproducible
@ -44,7 +45,7 @@ def main():
known = Node('34.204.196.211', 9796)
known_r = RankedNode(known, initial_rank)
g = build_graph(edges, initial_rank=initial_rank)
cnt = 0
# cnt = 0
# destinations = []
# for node in g:
# destinations.append(node)
@ -53,8 +54,10 @@ def main():
# break
destinations = sample(list(g.nodes()), churned_peers)
print(f'!!!!!! adding destinations: {destinations}')
for node in destinations:
g.add_edge(known_r, node)
# g.add_edge(node, known_r)
count_map = {}
for node in g:

View File

@ -10,7 +10,8 @@ def load_data(path):
for file in glob.glob(path):
with open(file, 'r') as f:
lines = list(map(lambda l: l.strip(), f))
bucket = datetime.fromtimestamp(float(file[22:-4]))
ts = file.split('_')[-1][:-4]
bucket = datetime.fromtimestamp(float(ts))
data = {}
data['avg_out'] = float(lines[1].split(': ')[1])
data['min_out'] = float(lines[2].split(': ')[1].split(', ')[3][0:-1])
@ -37,9 +38,10 @@ def load_data(path):
def main():
for edges in [20, 30, 40, 50, 60, 70, 80, 90, 100]:
# for edges in [0, 20, 30, 40, 50, 60, 70, 80, 90, 100, 130, 150, 200]:
for edges in [3, 5, 10]:
print(f'plotting for {edges} edges')
all_data = load_data(f'./churn_rank/{edges}*')
all_data = load_data(f'./churn_rank/{edges}_*')
x = []
avg_out = []
min_out = []
@ -105,6 +107,7 @@ def main():
ax.plot(x, sr_perc_80, label='sr_perc_80')
ax.plot(x, sr_perc_90, label='sr_perc_90')
ax.plot(x, sr_perc_95, label='sr_perc_95')
ax.plot(x, avg_sr, label='avg_sr')
ax.set_title(f'SensorRank after adding {edges} edges')
fig.autofmt_xdate()
@ -122,6 +125,7 @@ def main():
ax.plot(x, pr_perc_80, label='pr_perc_80')
ax.plot(x, pr_perc_90, label='pr_perc_90')
ax.plot(x, pr_perc_95, label='pr_perc_95')
ax.plot(x, avg_pr, label='avg_pr')
ax.set_title(f'PageRank after adding {edges} edges')
fig.autofmt_xdate()