Python networkx 模块,eigenvector_centrality() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用networkx.eigenvector_centrality()

项目:Visualization-of-popular-algorithms-in-Python    作者:MUSoC    | 项目源码 | 文件源码
def CentralityMeasures(G):
    # Betweenness centrality
    bet_cen = nx.betweenness_centrality(G)
    # Closeness centrality
    clo_cen = nx.closeness_centrality(G)
    # Eigenvector centrality
    eig_cen = nx.eigenvector_centrality(G)
    # Degree centrality
    deg_cen = nx.degree_centrality(G)
    #print bet_cen, clo_cen, eig_cen
    print "# Betweenness centrality:" + str(bet_cen)
    print "# Closeness centrality:" + str(clo_cen)
    print "# Eigenvector centrality:" + str(eig_cen)
    print "# Degree centrality:" + str(deg_cen)


#main function
项目:Visualization-of-popular-algorithms-in-Python    作者:MUSoC    | 项目源码 | 文件源码
def CentralityMeasures(G):
    # Betweenness centrality
    bet_cen = nx.betweenness_centrality(G)
    # Closeness centrality
    clo_cen = nx.closeness_centrality(G)
    # Eigenvector centrality
    eig_cen = nx.eigenvector_centrality(G)
    # Degree centrality
    deg_cen = nx.degree_centrality(G)
    #print bet_cen, clo_cen, eig_cen
    print "# Betweenness centrality:" + str(bet_cen)
    print "# Closeness centrality:" + str(clo_cen)
    print "# Eigenvector centrality:" + str(eig_cen)
    print "# Degree centrality:" + str(deg_cen)


#main function
项目:Visualization-of-popular-algorithms-in-Python    作者:MUSoC    | 项目源码 | 文件源码
def CentralityMeasures(G):
    # Betweenness centrality
    bet_cen = nx.betweenness_centrality(G)
    # Closeness centrality
    clo_cen = nx.closeness_centrality(G)
    # Eigenvector centrality
    eig_cen = nx.eigenvector_centrality(G)
    # Degree centrality
    deg_cen = nx.degree_centrality(G)
    #print bet_cen, clo_cen, eig_cen
    print "# Betweenness centrality:" + str(bet_cen)
    print "# Closeness centrality:" + str(clo_cen)
    print "# Eigenvector centrality:" + str(eig_cen)
    print "# Degree centrality:" + str(deg_cen)


#main function
项目:facebook-message-analysis    作者:szheng17    | 项目源码 | 文件源码
def get_user_to_eigenvector_centrality(self, G):
        return nx.eigenvector_centrality(G)
项目:ocean    作者:worldoss    | 项目源码 | 文件源码
def central_list(E):
    centralities = []
    centralities.append(nx.in_degree_centrality(E))
    centralities.append(nx.out_degree_centrality(E))
    centralities.append(nx.closeness_centrality(E))
    centralities.append(nx.betweenness_centrality(E))
    centralities.append(nx.eigenvector_centrality(E))

    for node in E.nodes_iter():
      measures = ("\t").join(map(lambda f: str(f[node]), centralities))
      print("%s: %s" % (node, measures))
项目:PhD    作者:wutaoadeny    | 项目源码 | 文件源码
def Eigen_Centrality(G):
    Eigen_Centrality = nx.eigenvector_centrality(G)
    #print "Eigen_Centrality:", sorted(Eigen_Centrality.iteritems(), key=lambda d:d[1], reverse = True)
    return Eigen_Centrality


#*****************************************************************************
项目:PhD    作者:wutaoadeny    | 项目源码 | 文件源码
def Eigen_Centrality(G):
    Eigen_Centrality = nx.eigenvector_centrality(G)
    #print "Eigen_Centrality:", sorted(Eigen_Centrality.iteritems(), key=lambda d:d[1], reverse = True)
    return Eigen_Centrality


#**********************************************************************************
项目:anomalous-vertices-detection    作者:Kagandi    | 项目源码 | 文件源码
def eigenvector(self):
        """ Compute the eigenvector centrality for the graph G.

        Returns
        -------
        nodes : dictionary
            Dictionary of nodes with eigenvector centrality as the value.

        Examples
        --------
        >>>
        """
        return nx.eigenvector_centrality(self._graph, weight=self._weight_field)

    # @property
项目:HRG    作者:nddsg    | 项目源码 | 文件源码
def draw_network_value(orig_g, mG):
    """
    Network values: The distribution of eigenvector components (indicators of "network value")
    associated to the largest eigenvalue of the graph adjacency matrix has also been found to be
    skewed (Chakrabarti et al., 2004).
    """
    eig_cents = [nx.eigenvector_centrality_numpy(g) for g in mG]  # nodes with eigencentrality

    srt_eig_cents = sorted(eig_cents, reverse=True)
    net_vals = []
    for cntr in eig_cents:
        net_vals.append(sorted(cntr.values(), reverse=True))
    df = pd.DataFrame(net_vals)

    plt.xscale('log')
    plt.yscale('log')
    plt.fill_between(df.columns, df.mean() - df.sem(), df.mean() + df.sem(), color='blue', alpha=0.2, label="se")

    h, = plt.plot(df.mean(), color='blue', aa=True, linewidth=4, ls='--', label="H*")
    orig, = plt.plot(sorted(nx.eigenvector_centrality(orig_g).values(), reverse=True), color='black', linewidth=4,
                     ls='-', label="H")

    plt.title('Principle Eigenvector Distribution')
    plt.ylabel('Principle Eigenvector')
    plt.tick_params(
        axis='x',  # changes apply to the x-axis
        which='both',  # both major and minor ticks are affected
        bottom='off',  # ticks along the bottom edge are off
        top='off',  # ticks along the top edge are off
        labelbottom='off')  # labels along the bottom edge are off

    plt.legend([orig, h], ['$H$', 'HRG $H^*$'], loc=3)
    # fig = plt.gcf()
    # fig.set_size_inches(5, 4, forward=True)
    plt.show()