如果要使用这种配置模型,NetworkX中应该可以使用这样的配置模型:import random
import networkx as nx
z=[int(random.gammavariate(alpha=9.0,beta=2.0)) for i in range(100)]
G=nx.configuration_model(z)
可能需要根据gamma分布中的参数调整序列z的平均值。同时z不需要是图形的(你会得到一个多重图),但是它需要一个偶数和,所以你可能需要尝试一些随机序列(或者加1)。。。
configuration_model的NetworkX文档说明提供了另一个示例、参考以及如何删除平行边和自循环:Notes
-----
As described by Newman [1]_.
A non-graphical degree sequence (not realizable by some simple
graph) is allowed since this function returns graphs with self
loops and parallel edges. An exception is raised if the degree
sequence does not have an even sum.
This configuration model construction process can lead to
duplicate edges and loops. You can remove the self-loops and
parallel edges (see below) which will likely result in a graph
that doesn't have the exact degree s