def main(): citation_graph = load_citation_graph() in_degress_dis = in_degree_distribution(citation_graph) plot_size = sum(in_degress_dis.values()) # normalize the distribution # (make the values in the dictionary sum to one) for in_degress in in_degress_dis: in_degress_dis[in_degress] /= float(plot_size) plot = [] # for input_val in range(plot_size): for input_val in range(2, plot_size): if not in_degress_dis.get(input_val): continue counter = in_degress_dis[input_val] plot.append([input_val, counter]) plot_x = lambda xy: [x[0] for x in xy] plot_y = lambda xy: [x[1] for x in xy] plt.loglog(plot_x(plot), plot_y(plot)) plt.xlabel("Input") plt.ylabel("Counter") plt.title("Iteration counts") plt.grid(True) plt.show()
def main(): # pp = [0.45, 0.5, 0.55] pp = [0.55] ns = 1000 for p in pp: citation_graph = Alg_ER(ns, p) in_degress_dis = in_degree_distribution(citation_graph) plot_size = sum(in_degress_dis.values()) # normalize the distribution # (make the values in the dictionary sum to one) for in_degress in in_degress_dis: in_degress_dis[in_degress]/=float(plot_size) plot = [] # for input_val in range(plot_size): for input_val in range(2, plot_size): if not in_degress_dis.get(input_val): continue counter = in_degress_dis[input_val] plot.append([input_val, counter]) plot_x = lambda xy: [x[0] for x in xy] plot_y = lambda xy: [x[1] for x in xy] # plot.append([math.log(input_val), math.log(counter)]) plot2 = [] for input_val, counter in plot: plot2.append([math.log(input_val), math.log(counter)]) # plt.loglog(plot_x(plot), plot_y(plot), color = 'r') plt.plot(plot_x(plot2), plot_y(plot2), color = 'r') plt.plot(plot_x(plot), plot_y(plot), color = 'g') plt.xlabel('Input') plt.ylabel('Counter') plt.title('Nodes(%d), P(%.2f)' % (ns, p)) plt.grid(True) plt.show()