def make_frame(self): fig = plt.figure(figsize=(5, 5)) ax = fig.add_subplot(111) graph = self.graph.handle dst = degrees_to_hist(graph.degree()) ccdf = sna.ccdf(dst) ax.loglog(ccdf) return fig
def make_distributions(arg): if isinstance(arg, nx.Graph): values = arg.degree().values() elif isinstance(arg, collections.Sequence): values = arg elif isinstance(arg, ndarray): values = arg.flatten() else: raise TypeError("Don't know what to do with %s" % arg) bins = np.bincount(values) ccdf = sna.ccdf(bins) pdf = np.asfarray(bins) / np.sum(bins) return ccdf, pdf
for _iteration in xrange(ITERATIONS): sim = barabasi_albert.BA() sim.setup_parameters(starting_edges=11, starting_network_size=11, steps=STEPS) sim.run() label = '%d starting size' % sim.starting_network_size steps = sim.steps starting_edges = sim.starting_edges starting_networks_size = sim.starting_network_size graph = sim.graph.handle del sim bins = np.bincount(graph.degree().values()) ccdf = sna.ccdf(bins) pdf = np.asfarray(bins) / len(bins) ba_ccdfs.append(ccdf) ba_pdfs.append(pdf) ccdf_axes = F_ccdf.gca() pdf_axes = F_pdf.gca() for dst, color in zip(ba_ccdfs, colors): ccdf_axes.loglog(dst, color=color) #ccdf_axes.loglog(ba_avg_ccdf, color='red') ccdf_axes.set_title('CCDF BA(%d, %d)' % (steps, starting_edges)) ccdf_axes.set_xlabel('Degree $x$')
def make_distributions(graph): bins = np.bincount(graph.degree().values()) ccdf = sna.ccdf(bins) pdf = np.asfarray(bins) / np.sum(bins) return ccdf, pdf