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


Python networkx.eccentricity方法代码示例

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


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

示例1: test_eccentricity

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity(self):
        assert_equal(networkx.eccentricity(self.G,1),6)
        e=networkx.eccentricity(self.G)
        assert_equal(e[1],6)
        sp=networkx.shortest_path_length(self.G)
        e=networkx.eccentricity(self.G,sp=sp)
        assert_equal(e[1],6)
        e=networkx.eccentricity(self.G,v=1)
        assert_equal(e,6)
        e=networkx.eccentricity(self.G,v=[1,1])  #This behavior changed in version 1.8 (ticket #739)
        assert_equal(e[1],6)
        e=networkx.eccentricity(self.G,v=[1,2])
        assert_equal(e[1],6)
        # test against graph with one node
        G=networkx.path_graph(1)
        e=networkx.eccentricity(G)
        assert_equal(e[0],0)
        e=networkx.eccentricity(G,v=0)
        assert_equal(e,0)
        assert_raises(networkx.NetworkXError, networkx.eccentricity, G, 1)
        # test against empty graph
        G=networkx.empty_graph()
        e=networkx.eccentricity(G)
        assert_equal(e,{}) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:26,代码来源:test_distance_measures.py

示例2: test_eccentricity

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity(self):
        assert_equal(networkx.eccentricity(self.G, 1), 6)
        e = networkx.eccentricity(self.G)
        assert_equal(e[1], 6)
        sp = dict(networkx.shortest_path_length(self.G))
        e = networkx.eccentricity(self.G, sp=sp)
        assert_equal(e[1], 6)
        e = networkx.eccentricity(self.G, v=1)
        assert_equal(e, 6)
        # This behavior changed in version 1.8 (ticket #739)
        e = networkx.eccentricity(self.G, v=[1, 1])
        assert_equal(e[1], 6)
        e = networkx.eccentricity(self.G, v=[1, 2])
        assert_equal(e[1], 6)
        # test against graph with one node
        G = networkx.path_graph(1)
        e = networkx.eccentricity(G)
        assert_equal(e[0], 0)
        e = networkx.eccentricity(G, v=0)
        assert_equal(e, 0)
        assert_raises(networkx.NetworkXError, networkx.eccentricity, G, 1)
        # test against empty graph
        G = networkx.empty_graph()
        e = networkx.eccentricity(G)
        assert_equal(e, {}) 
开发者ID:holzschu,项目名称:Carnets,代码行数:27,代码来源:test_distance_measures.py

示例3: _create_node_feature_matrix

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def _create_node_feature_matrix(self, graph):
        """
        Calculating the node features.

        Arg types:
            * **graph** *(NetworkX graph)* - The graph of interest.

        Return types:
            * **X** *(NumPy array)* - The node features.
        """
        log_degree = np.array([math.log(graph.degree(node)+1) for node in range(graph.number_of_nodes())]).reshape(-1, 1)
        eccentricity = np.array([nx.eccentricity(graph, node) for node in range(graph.number_of_nodes())]).reshape(-1, 1)
        clustering_coefficient = np.array([nx.clustering(graph, node) for node in range(graph.number_of_nodes())]).reshape(-1, 1)
        X = np.concatenate([log_degree, eccentricity, clustering_coefficient], axis=1)
        return X 
开发者ID:benedekrozemberczki,项目名称:karateclub,代码行数:17,代码来源:geoscattering.py

示例4: test_eccentricity_infinite

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity_infinite(self):
        G=networkx.Graph([(1,2),(3,4)])
        e = networkx.eccentricity(G) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:5,代码来源:test_distance_measures.py

示例5: test_eccentricity_invalid

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity_invalid(self):
        G=networkx.Graph([(1,2),(3,4)])
        e = networkx.eccentricity(G,sp=1) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:5,代码来源:test_distance_measures.py

示例6: test_eccentricity_infinite

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity_infinite(self):
        G = networkx.Graph([(1, 2), (3, 4)])
        e = networkx.eccentricity(G) 
开发者ID:holzschu,项目名称:Carnets,代码行数:5,代码来源:test_distance_measures.py

示例7: test_eccentricity_undirected_not_connected

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity_undirected_not_connected(self):
        G = networkx.Graph([(1, 2), (3, 4)])
        e = networkx.eccentricity(G, sp=1) 
开发者ID:holzschu,项目名称:Carnets,代码行数:5,代码来源:test_distance_measures.py

示例8: test_eccentricity_directed_weakly_connected

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import eccentricity [as 别名]
def test_eccentricity_directed_weakly_connected(self):
        DG = networkx.DiGraph([(1, 2), (1, 3)])
        networkx.eccentricity(DG) 
开发者ID:holzschu,项目名称:Carnets,代码行数:5,代码来源:test_distance_measures.py


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