本文整理匯總了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
示例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),{})
示例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})
示例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})
示例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])
示例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])
示例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), {})
示例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})
示例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})
示例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])
示例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])