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


Python networkx.square_clustering方法代码示例

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


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

示例1: clustering

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def clustering(graph, name="cluster"):
    """
    Calculates the squares clustering coefficient for nodes.

    Wrapper around ``networkx.square_clustering``.


    Parameters
    ----------
    graph : networkx.Graph
        Graph representing street network.
        Ideally generated from GeoDataFrame using :func:`momepy.gdf_to_nx`
    name : str, optional
        calculated attribute name

    Returns
    -------
    Graph
        networkx.Graph

    Examples
    --------
    >>> network_graph = mm.clustering(network_graph)
    """
    netx = graph.copy()

    vals = nx.square_clustering(netx)
    nx.set_node_attributes(netx, vals, name)

    return netx 
开发者ID:martinfleis,项目名称:momepy,代码行数:32,代码来源:graph.py

示例2: test_clustering

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_clustering(self):
        G = nx.Graph()
        assert_equal(list(nx.square_clustering(G).values()),[])
        assert_equal(nx.square_clustering(G),{}) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:6,代码来源:test_cluster.py

示例3: test_path

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_path(self):
        G = nx.path_graph(10)
        assert_equal(list(nx.square_clustering(G).values()),
                     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
        assert_equal(nx.square_clustering(G),
                     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 
                      5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0}) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:9,代码来源:test_cluster.py

示例4: test_cubical

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_cubical(self):
        G = nx.cubical_graph()
        assert_equal(list(nx.square_clustering(G).values()),
                     [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
        assert_equal(list(nx.square_clustering(G,[1,2]).values()),[0.5, 0.5])
        assert_equal(nx.square_clustering(G,[1])[1],0.5)
        assert_equal(nx.square_clustering(G,[1,2]),{1: 0.5, 2: 0.5}) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:9,代码来源:test_cluster.py

示例5: test_k5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_k5(self):
        G = nx.complete_graph(5)
        assert_equal(list(nx.square_clustering(G).values()),[1, 1, 1, 1, 1]) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:5,代码来源:test_cluster.py

示例6: test_bipartite_k5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_bipartite_k5(self):
        G = nx.complete_bipartite_graph(5,5)
        assert_equal(list(nx.square_clustering(G).values()),
                        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:6,代码来源:test_cluster.py

示例7: test_clustering

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_clustering(self):
        G = nx.Graph()
        assert_equal(list(nx.square_clustering(G).values()), [])
        assert_equal(nx.square_clustering(G), {}) 
开发者ID:holzschu,项目名称:Carnets,代码行数:6,代码来源:test_cluster.py

示例8: test_path

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_path(self):
        G = nx.path_graph(10)
        assert_equal(list(nx.square_clustering(G).values()),
                     [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
        assert_equal(nx.square_clustering(G),
                     {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0,
                      5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0}) 
开发者ID:holzschu,项目名称:Carnets,代码行数:9,代码来源:test_cluster.py

示例9: test_cubical

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_cubical(self):
        G = nx.cubical_graph()
        assert_equal(list(nx.square_clustering(G).values()),
                     [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
        assert_equal(list(nx.square_clustering(G, [1, 2]).values()), [0.5, 0.5])
        assert_equal(nx.square_clustering(G, [1])[1], 0.5)
        assert_equal(nx.square_clustering(G, [1, 2]), {1: 0.5, 2: 0.5}) 
开发者ID:holzschu,项目名称:Carnets,代码行数:9,代码来源:test_cluster.py

示例10: test_k5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_k5(self):
        G = nx.complete_graph(5)
        assert_equal(list(nx.square_clustering(G).values()), [1, 1, 1, 1, 1]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:5,代码来源:test_cluster.py

示例11: test_bipartite_k5

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import square_clustering [as 别名]
def test_bipartite_k5(self):
        G = nx.complete_bipartite_graph(5, 5)
        assert_equal(list(nx.square_clustering(G).values()),
                     [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:6,代码来源:test_cluster.py


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