networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
expected_degree_graph(w, seed=None, selfloops=True)

Given a sequence of expected degrees $W=(w_0,w_1,\ldots,w_{n-1})$ of length $n$ this algorithm assigns an edge between node $u$ and node $v$ with probability

$$p_{uv} = \frac{w_u w_v}{\sum_k w_k} .$$

Notes

The nodes have integer labels corresponding to index of expected degrees input sequence.

The complexity of this algorithm is $\mathcal{O}(n+m)$ where $n$ is the number of nodes and $m$ is the expected number of edges.

The model in includes the possibility of self-loop edges. Set selfloops=False to produce a graph without self loops.

For finite graphs this model doesn't produce exactly the given expected degree sequence. Instead the expected degrees are as follows.

For the case without self loops (selfloops=False),

$$E[deg(u)] = \sum_{v \ne u} p_{uv} = w_u \left( 1 - \frac{w_u}{\sum_k w_k} \right) .$$

NetworkX uses the standard convention that a self-loop edge counts 2 in the degree of a node, so with self loops (selfloops=True),

$$E[deg(u)] = \sum_{v \ne u} p_{uv} + 2 p_{uu} = w_u \left( 1 + \frac{w_u}{\sum_k w_k} \right) .$$

Parameters

w : list

The list of expected degrees.

selfloops: bool (default=True) :

Set to False to remove the possibility of self-loop edges.

seed : integer, random_state, or None (default)

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

Returns

Graph

Returns a random graph with given expected degrees.

Examples

>>> z = [10 for i in range(100)]
... G = nx.expected_degree_graph(z)
See :

Back References

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

networkx.generators.degree_seq.expected_degree_graph networkx.generators.random_graphs.random_kernel_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/degree_seq.py#332
type: <class 'function'>
Commit: