Fix refactored experiments

This commit is contained in:
Marcin Kostrzewski 2022-06-21 16:28:11 +02:00
parent 8fe3c2bf8e
commit 6f8563f7d8

View File

@ -201,35 +201,42 @@ def summary(average_degrees: list[float], propagation_speeds: list[float]) -> No
plt.show() plt.show()
def experiment(network, avg_degree, node_count): def experiment(network, avg_degree, node_count, iteration):
degrees = [] degrees = []
speeds = [] speeds = []
sizes = [0, 8, 15] do_graph_animation(f'bus{iteration}.gif', network, 90, nx.spiral_layout)
for i in sizes: speeds.append(network.rounds_survived / node_count)
do_graph_animation(f'bus{i}.gif', network, 90, nx.spiral_layout) degrees.append(avg_degree)
speeds.append(network.rounds_survived / node_count) print(f"\n{node_count} NODE BUS")
degrees.append(avg_degree) print(f"average degree = {avg_degree}")
print(f"\n{node_count} NODE BUS") print(f"propagation speed = {round(speeds[-1], 2)}")
print(f"average degree = {avg_degree}") print(f"bus_{iteration} rounds survived = {network.rounds_survived + 1}")
print(f"propagation speed = {round(speeds[-1], 2)}")
print(f"bus_{i} rounds survived = {network.rounds_survived + 1}")
summary(degrees, speeds) summary(degrees, speeds)
def bus_experiment(): def bus_experiment():
bus, bus_avg_degree, node_count = bus_network(20 + i) sizes = [0, 8, 15]
experiment(bus, bus_avg_degree, node_count) for i in sizes:
bus, bus_avg_degree, node_count = bus_network(20 + i)
experiment(bus, bus_avg_degree, node_count, i)
def ring_experiment(): def ring_experiment():
ring, ring_avg_degree, node_count = ring_network(20 + i) sizes = [0, 8, 15]
experiment(ring, ring_avg_degree, node_count) for i in sizes:
ring, ring_avg_degree, node_count = ring_network(20 + i)
experiment(ring, ring_avg_degree, node_count, i)
def star_experiment(): def star_experiment():
star, star_avg_degree, node_count = star_network(cluster_count=3 + i, starsize=3 + i) sizes = [0, 8, 15]
experiment(star, star_avg_degree, node_count) for i in sizes:
star, star_avg_degree, node_count = star_network(cluster_count=3 + i, starsize=3 + i)
experiment(star, star_avg_degree, node_count, i)
def weighted_star_experiment():
def main(): def main():