当前位置: 首页>>代码示例>>Python>>正文


Python networkx.katz_centrality方法代码示例

本文整理汇总了Python中networkx.katz_centrality方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.katz_centrality方法的具体用法?Python networkx.katz_centrality怎么用?Python networkx.katz_centrality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在networkx的用法示例。


在下文中一共展示了networkx.katz_centrality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _calc_graph_func

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def _calc_graph_func(p):
    con, times_chunk, graph_func = p
    vals = []
    now = time.time()
    for run, t in enumerate(times_chunk):
        utils.time_to_go(now, run, len(times_chunk), 10)
        con_t = con[:, :, t]
        g = nx.from_numpy_matrix(con_t)
        if graph_func == 'closeness_centrality':
            x = nx.closeness_centrality(g)
        elif graph_func == 'degree_centrality':
            x = nx.degree_centrality(g)
        elif graph_func == 'eigenvector_centrality':
            x = nx.eigenvector_centrality(g, max_iter=10000)
        elif graph_func == 'katz_centrality':
            x = nx.katz_centrality(g, max_iter=100000)
        else:
            raise Exception('Wrong graph func!')
        vals.append([x[k] for k in range(len(x))])
    vals = np.array(vals)
    return vals, times_chunk 
开发者ID:pelednoam,项目名称:mmvt,代码行数:23,代码来源:analyse_meg_epilepsy_clips.py

示例2: __init__

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def __init__(self, method='degree', analyzer=NltkNormalizer().split_and_normalize):
        self.analyze = analyzer
        self.method = method
        self.methods_on_digraph = {'hits', 'pagerank', 'katz'}
        self._get_scores = {'degree': nx.degree, 'betweenness': nx.betweenness_centrality,
                            'pagerank': nx.pagerank_scipy, 'hits': self._hits, 'closeness': nx.closeness_centrality,
                            'katz': nx.katz_centrality}[method]
        # Add a new value when a new vocabulary item is seen
        self.vocabulary = defaultdict()
        self.vocabulary.default_factory = self.vocabulary.__len__ 
开发者ID:quadflor,项目名称:Quadflor,代码行数:12,代码来源:graph_score_vectorizer.py

示例3: test_K5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_K5(self):
        """Katz centrality: K5"""
        G = networkx.complete_graph(5)
        alpha = 0.1
        b = networkx.katz_centrality(G, alpha)
        v = math.sqrt(1 / 5.0)
        b_answer = dict.fromkeys(G, v)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n])
        nstart = dict([(n, 1) for n in G])
        b = networkx.katz_centrality(G, alpha, nstart=nstart)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n]) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:15,代码来源:test_katz_centrality.py

示例4: test_P3

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_P3(self):
        """Katz centrality: P3"""
        alpha = 0.1
        G = networkx.path_graph(3)
        b_answer = {0: 0.5598852584152165, 1: 0.6107839182711449,
                    2: 0.5598852584152162}
        b = networkx.katz_centrality(G, alpha)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n], places=4) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:11,代码来源:test_katz_centrality.py

示例5: test_maxiter

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_maxiter(self):
        alpha = 0.1
        G = networkx.path_graph(3)
        max_iter = 0
        try:
            b = networkx.katz_centrality(G, alpha, max_iter=max_iter)
        except networkx.NetworkXError as e:
            assert str(max_iter) in e.args[0], "max_iter value not in error msg"
            raise # So that the decorater sees the exception. 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:11,代码来源:test_katz_centrality.py

示例6: test_beta_as_scalar

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_beta_as_scalar(self):
        alpha = 0.1
        beta = 0.1
        b_answer = {0: 0.5598852584152165, 1: 0.6107839182711449,
                    2: 0.5598852584152162}
        G = networkx.path_graph(3)
        b = networkx.katz_centrality(G, alpha, beta)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n], places=4) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:11,代码来源:test_katz_centrality.py

示例7: test_beta_as_dict

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_beta_as_dict(self):
        alpha = 0.1
        beta = {0: 1.0, 1: 1.0, 2: 1.0}
        b_answer = {0: 0.5598852584152165, 1: 0.6107839182711449,
                    2: 0.5598852584152162}
        G = networkx.path_graph(3)
        b = networkx.katz_centrality(G, alpha, beta)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n], places=4) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:11,代码来源:test_katz_centrality.py

示例8: test_multigraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_multigraph(self):
        e = networkx.katz_centrality(networkx.MultiGraph(), 0.1) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:4,代码来源:test_katz_centrality.py

示例9: test_empty

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_empty(self):
        e = networkx.katz_centrality(networkx.Graph(), 0.1)
        assert_equal(e, {}) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:5,代码来源:test_katz_centrality.py

示例10: test_bad_beta

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_bad_beta(self):
        G = networkx.Graph([(0,1)])
        beta = {0:77}
        e = networkx.katz_centrality(G, 0.1,beta=beta) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:6,代码来源:test_katz_centrality.py

示例11: test_bad_beta_numbe

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_bad_beta_numbe(self):
        G = networkx.Graph([(0,1)])
        e = networkx.katz_centrality(G, 0.1,beta='foo') 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:5,代码来源:test_katz_centrality.py

示例12: test_K5_unweighted

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_K5_unweighted(self):
        """Katz centrality: K5"""
        G = networkx.complete_graph(5)
        alpha = 0.1
        b = networkx.katz_centrality(G, alpha, weight=None)
        v = math.sqrt(1 / 5.0)
        b_answer = dict.fromkeys(G, v)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n])
        nstart = dict([(n, 1) for n in G])
        b = networkx.eigenvector_centrality_numpy(G)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n], places=3) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:15,代码来源:test_katz_centrality.py

示例13: test_katz_centrality_weighted

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_katz_centrality_weighted(self):
        G = self.G
        alpha = self.G.alpha
        p = networkx.katz_centrality(G, alpha)
        for (a, b) in zip(list(p.values()), self.G.evc):
            assert_almost_equal(a, b) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:8,代码来源:test_katz_centrality.py

示例14: test_katz_centrality_unweighted

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_katz_centrality_unweighted(self):
        G = self.H
        alpha = self.H.alpha
        p = networkx.katz_centrality(G, alpha)
        for (a, b) in zip(list(p.values()), self.G.evc):
            assert_almost_equal(a, b) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:8,代码来源:test_katz_centrality.py

示例15: test_K5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import katz_centrality [as 别名]
def test_K5(self):
        """Katz centrality: K5"""
        G = nx.complete_graph(5)
        alpha = 0.1
        b = nx.katz_centrality(G, alpha)
        v = math.sqrt(1 / 5.0)
        b_answer = dict.fromkeys(G, v)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n])
        nstart = dict([(n, 1) for n in G])
        b = nx.katz_centrality(G, alpha, nstart=nstart)
        for n in sorted(G):
            assert_almost_equal(b[n], b_answer[n]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:15,代码来源:test_katz_centrality.py


注:本文中的networkx.katz_centrality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。