planted_partition_graph#

planted_partition_graph(l, k, p_in, p_out, seed=None, directed=False)[source]#

返回 planted l 分区图。

此模型将一个包含 n=l*k 个顶点的图划分为 l 个组,每组包含 k 个顶点。同一组内的顶点以概率 p_in 连接,不同组间的顶点以概率 p_out 连接。

参数:
lint

组数

kint

每组中的顶点数

p_infloat

同一组内顶点连接的概率

p_outfloat

不同组间顶点连接的概率

seed整数、random_state 或 None(默认)

随机数生成状态的指示符。参阅 随机性

directedbool,可选(默认=False)

如果为 True,则返回一个有向图

返回:
GNetworkX Graph 或 DiGraph

planted l 分区图

引发:
NetworkXError

如果 p_inp_out 不在 [0, 1] 范围内

另请参见

random_partition_model

参考文献

[1]

A. Condon, R.M. Karp, Algorithms for graph partitioning on the planted partition model, Random Struct. Algor. 18 (2001) 116-140.

[2]

Santo Fortunato ‘Community Detection in Graphs’ Physical Reports Volume 486, Issue 3-5 p. 75-174. https://arxiv.org/abs/0906.0612

示例

>>> G = nx.planted_partition_graph(4, 3, 0.5, 0.1, seed=42)