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