networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersBackRef
random_kernel_graph(n, kernel_integral, kernel_root=None, seed=None)

The algorithm chooses each of the $[n(n-1)]/2$ possible edges with probability specified by a kernel $\kappa(x,y)$ . The kernel $\kappa(x,y)$ must be a symmetric (in $x,y$), non-negative, bounded function.

Notes

The kernel is specified through its definite integral which must be provided as one of the arguments. If the integral and root of the kernel integral can be found in $O(1)$ time then this algorithm runs in time $O(n+m)$ where m is the expected number of edges .

The nodes are set to integers from $0$ to $n-1$.

Parameters

n : int

The number of nodes

kernel_integral : function

Function that returns the definite integral of the kernel $\kappa(x,y)$, $F(y,a,b) := \int_a^b \kappa(x,y)dx$

kernel_root: function (optional) :

Function that returns the root $b$ of the equation $F(y,a,b) = r$. If None, the root is found using scipy.optimize.brentq (this requires SciPy).

seed : integer, random_state, or None (default)

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

Returns an random graph based on the specified kernel.

See Also

expected_degree_graph
gnp_random_graph

Examples

Generate an Erdős–Rényi random graph $G(n,c/n)$, with kernel $\kappa(x,y)=c$ where $c$ is the mean expected degree.

>>> def integral(u, w, z):
...  return c * (z - w)
... def root(u, w, r):
...  return r / c + w
... c = 1
... graph = nx.random_kernel_graph(1000, integral, root)
See :

Back References

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

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/random_graphs.py#1236
type: <class 'function'>
Commit: