本文整理汇总了Python中Graph.plot_maxload方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.plot_maxload方法的具体用法?Python Graph.plot_maxload怎么用?Python Graph.plot_maxload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.plot_maxload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_plots
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import plot_maxload [as 别名]
def create_plots():
"""
Execute simulations, gather data and plot it
First choose the graph sizes for which plots should be generated,
then the number of samples for each size.
Generate random graphs and perform each broadcasting algorithm on it.
Then get the number of retransmitting nodes, sent messages and max load of any node.
Finally plot it according to the graph's connectivity.
Argument:
--
Return-type:
Plot a graph with possibility to arrange and save it manually
"""
# max_size = 1
samples = 100
# x_lst = [i for i in range(2, max_size+1)]
x_lst = [3]
fig3 = plt.figure('Max buffer-length')
fig2 = plt.figure('Messages sent')
fig1 = plt.figure('Retransmitting nodes')
for index in range(len(x_lst)):
size = x_lst[index]
print size
if len(x_lst) == 1:
ax1 = fig1.add_subplot(1, 1, index + 1)
ax2 = fig2.add_subplot(1, 1, index + 1)
ax3 = fig3.add_subplot(1, 1, index + 1)
else:
ax1 = fig1.add_subplot(round(len(x_lst)/2, 0), 2, index + 1)
ax2 = fig2.add_subplot(round(len(x_lst)/2, 0), 2, index + 1)
ax3 = fig3.add_subplot(round(len(x_lst)/2, 0), 2, index + 1)
flood_mes = {}
ahbp_mes = {}
sba_mes = {}
flood_rebroad = {}
ahbp_rebroad = {}
sba_rebroad = {}
flood_max = {}
ahbp_max = {}
sba_max = {}
# for a in range(samples):
for a in range(samples):
conn = -1
while conn < 0:
graph, laplacian = random_graph(x_lst[index])
if x_lst[index] > 20:
conn = round(get_connectivity(laplacian), 4)
elif x_lst[index] == 20:
conn = round(get_connectivity(laplacian), 3)
else:
conn = round(get_connectivity(laplacian), 2)
# get values for flooding
setup_sending_flooding(graph)
flood_rebroad, flood_mes, flood_max = gather_data(graph, conn, flood_rebroad, flood_mes, flood_max)
# set all the sender flags to false again
# so one can reuse the same graph
clear_graph_data(graph)
# get values for AHBP
setup_sending_AHBP(graph)
ahbp_rebroad, ahbp_mes, ahbp_max = gather_data(graph, conn, ahbp_rebroad, ahbp_mes, ahbp_max)
clear_graph_data(graph)
# get values for SBA
setup_sending_SBA(graph, 2)
sba_rebroad, sba_mes, sba_max = gather_data(graph, conn, sba_rebroad, sba_mes, sba_max)
clear_graph_data(graph)
# plot number of retransmitting nodes
flood_rebroad = average_std(flood_rebroad)
ahbp_rebroad = average_std(ahbp_rebroad)
sba_rebroad = average_std(sba_rebroad)
Graph.plot_data(flood_rebroad, ahbp_rebroad, sba_rebroad, ax1)
# plot number of messages sent
flood_mes = average_std(flood_mes)
ahbp_mes = average_std(ahbp_mes)
sba_mes = average_std(sba_mes)
Graph.plot_data(flood_mes, ahbp_mes, sba_mes, ax2)
#plot max load of any node in the graph
flood_max, ahbp_max, sba_max = arrange_data(size, flood_max, ahbp_max, sba_max)
Graph.plot_maxload(flood_max, ax3, 'flood')
Graph.plot_maxload(ahbp_max, ax3, 'ahbp')
Graph.plot_maxload(sba_max, ax3, 'sba')
#format the plots
Graph.format_plots(ax1, size, 'retransmission')
Graph.format_plots(ax2, size, 'messages')
Graph.format_plots(ax3, size, 'max_load')
# add axis notations and stuff
Graph.format_figure(fig1, 'retransmission')
#.........这里部分代码省略.........