コード例 #1
0
ファイル: animation.py プロジェクト: rik0/pynetsym
 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
コード例 #2
0
ファイル: util.py プロジェクト: rik0/pynetsym
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
コード例 #3
0
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
コード例 #4
0
ファイル: multi_ba_sim.py プロジェクト: rik0/pynetsym
    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$')
コード例 #5
0
def make_distributions(graph):
    bins = np.bincount(graph.degree().values())
    ccdf = sna.ccdf(bins)
    pdf = np.asfarray(bins) / np.sum(bins)
    return ccdf, pdf
コード例 #6
0
def make_distributions(graph):
    bins = np.bincount(graph.degree().values())
    ccdf = sna.ccdf(bins)
    pdf = np.asfarray(bins) / np.sum(bins)
    return ccdf, pdf