networkx.generators.directed.random_k_out_graph¶

random_k_out_graph
(n, k, alpha, self_loops=True, seed=None)[source]¶ Returns a random
k
out graph with preferential attachment.A random
k
out graph with preferential attachment is a multidigraph generated by the following algorithm.Begin with an empty digraph, and initially set each node to have weight
alpha
.Choose a node
u
with outdegree less thank
uniformly at random.Choose a node
v
from with probability proportional to its weight.Add a directed edge from
u
tov
, and increase the weight ofv
by one.If each node has outdegree
k
, halt, otherwise repeat from step 2.
For more information on this model of random graph, see [1].
 Parameters
n (int) – The number of nodes in the returned graph.
k (int) – The outdegree of each node in the returned graph.
alpha (float) – A positive
float
representing the initial weight of each vertex. A higher number means that in step 3 above, nodes will be chosen more like a true uniformly random sample, and a lower number means that nodes are more likely to be chosen as their indegree increases. If this parameter is not positive, aValueError
is raised.self_loops (bool) – If True, selfloops are allowed when generating the graph.
seed (integer, random_state, or None (default)) – Indicator of random number generation state. See Randomness.
 Returns
A
k
outregular multidigraph generated according to the above algorithm. Return type
MultiDiGraph
 Raises
ValueError – If
alpha
is not positive.
Notes
The returned multidigraph may not be strongly connected, or even weakly connected.
References
 [1]: Peterson, Nicholas R., and Boris Pittel.
“Distance between two random
k
out digraphs, with and without preferential attachment.” arXiv preprint arXiv:1311.5961 (2013). <https://arxiv.org/abs/1311.5961>