當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。