random_k_out_graph(n, k, alpha, self_loops=True, seed=None)
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 :None:None:`u`
with out-degree less than k
uniformly at random.
Choose a node :None:None:`v`
from with probability proportional to its weight.
Add a directed edge from :None:None:`u`
to :None:None:`v`
, and increase the weight of :None:None:`v`
by one.
If each node has out-degree k
, halt, otherwise repeat from step 2.
For more information on this model of random graph, see [1].
The returned multidigraph may not be strongly connected, or even weakly connected.
The number of nodes in the returned graph.
The out-degree of each node in the returned graph.
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 in-degree increases. If this parameter is not positive, a ValueError
is raised.
If True, self-loops are allowed when generating the graph.
Indicator of random number generation state. See Randomness<randomness>
.
If alpha
is not positive.
A k
-out-regular multidigraph generated according to the above algorithm.
Returns a random k
-out graph with preferential attachment.
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.generators.directed.random_uniform_k_out_graph
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them