networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
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.

  1. Begin with an empty digraph, and initially set each node to have weight alpha .

  2. Choose a node :None:None:`u` with out-degree less than k uniformly at random.

  3. Choose a node :None:None:`v` from with probability proportional to its weight.

  4. Add a directed edge from :None:None:`u` to :None:None:`v`, and increase the weight of :None:None:`v` by one.

  5. If each node has out-degree k, halt, otherwise repeat from step 2.

For more information on this model of random graph, see [1].

Notes

The returned multidigraph may not be strongly connected, or even weakly connected.

Parameters

n : int

The number of nodes in the returned graph.

k : int

The out-degree 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 in-degree increases. If this parameter is not positive, a ValueError is raised.

self_loops : bool

If True, self-loops are allowed when generating the graph.

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

Raises

ValueError

If alpha is not positive.

Returns

:class:`~networkx.classes.MultiDiGraph`

A k-out-regular multidigraph generated according to the above algorithm.

Returns a random k-out graph with preferential attachment.

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.generators.directed.random_uniform_k_out_graph

Local connectivity 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


GitHub : /networkx/generators/directed.py#410
type: <class 'function'>
Commit: