generate_s1

Contents

generate_s1#

graph_tool.generation.generate_s1(N=None, beta=2.5, gamma=2.5, average_degree=10, kappa=None, hyperbolic=False)[git][source]#

Generate a graph with the \(\mathbb{S}^1\) geometric model (or its hyperbolic version \(\mathbb{H}^2\)).

Parameters:
Nint (optional, default: None)

Number of vertices. Needed if kappa is not given.

betafloat (optional, default: 2.5)

Inverse temperature, larger than one, which controls the clustering.

gammafloat (optional, default: 2.5)

Exponent of the power-law distribution of the hidden degrees, larger than two. Ignored if kappa is given.

average_degreefloat (optional, default: 10)

Expected average degree.

kappaiterable of float (optional, default: None)

Hidden degrees of the vertices. If not given, they are sampled from a power law with exponent gamma.

hyperbolicbool (optional, default: False)

If True, the radial coordinates of the vertices in the hyperbolic plane are also returned.

Returns:
gGraph

The generated undirected graph.

kappaVertexPropertyMap

The hidden degree of every vertex.

thetaVertexPropertyMap

The angular coordinate of every vertex.

rVertexPropertyMap

The radial coordinate of every vertex in \(\mathbb{H}^2\). Only returned if hyperbolic == True.

See also

geometric_graph

Geometric graph

generate_soft_geometric

Soft random geometric graph

generate_chung_lu

Graphs with given expected degrees

Notes

In the \(\mathbb{S}^1\) model [serrano-self-similarity-2008], every vertex \(u\) has a hidden degree \(\kappa_u\) and an angle \(\theta_u\), uniformly distributed on a circle of radius \(R = N/2\pi\), and every pair is connected with probability

\[p_{uv} = \frac{1}{1 + \left(\frac{R\Delta\theta_{uv}} {\mu\kappa_u\kappa_v}\right)^\beta},\]

where \(\Delta\theta_{uv}\) is their angular distance and \(\mu = \beta\sin(\pi/\beta)/(2\pi\langle k\rangle)\), so that the expected degree of every vertex is approximately its hidden degree. The model is equivalent to random hyperbolic graphs in the hyperbolic plane \(\mathbb{H}^2\) [krioukov-hyperbolic-2010], with the radial coordinates \(r_u = \hat R - 2\ln(\kappa_u/\kappa_0)\), where \(\hat R = 2\ln[N/(\mu\pi\kappa_0^2)]\) and \(\kappa_0\) is the smallest hidden degree. The hidden degrees are sampled from the power law \(P(\kappa)\propto\kappa^{-\gamma}\) for \(\kappa_0 \le \kappa \le \kappa_0N^{1/(\gamma-1)}\), with \(\kappa_0\) chosen so that their mean is average_degree.

Instead of considering all \(O(N^2)\) pairs, the vertices are grouped by hidden degrees within a factor of two, and for every vertex and group the vertices of the group are scanned in order of angular distance, in blocks of doubling size, within which candidates are drawn with geometric skips according to an upper bound of the probability at the start of the block, and accepted with the ratio of the true probability to the bound. This takes time \(O(NL\log N + E)\), where \(L\) is the number of groups.

References

[serrano-self-similarity-2008]

M. Ángeles Serrano, Dmitri Krioukov and Marián Boguñá, “Self-similarity of complex networks and hidden metric spaces”, Physical Review Letters 100, 078701 (2008), DOI: 10.1103/PhysRevLett.100.078701 [sci-hub, @tor], arXiv: 0710.2092

[krioukov-hyperbolic-2010]

Dmitri Krioukov, Fragkiskos Papadopoulos, Maksim Kitsak, Amin Vahdat and Marián Boguñá, “Hyperbolic geometry of complex networks”, Physical Review E 82, 036106 (2010), DOI: 10.1103/PhysRevE.82.036106 [sci-hub, @tor], arXiv: 1006.5169

Examples

>>> g, kappa, theta = gt.generate_s1(10000, beta=3, gamma=2.5,
...                                  average_degree=8)
>>> print(2 * g.num_edges() / g.num_vertices(), gt.global_clustering(g)[0])
7.9756 0.0954617...

A smaller instance in its hyperbolic representation, with every vertex \(u\) placed at the polar coordinates \((r_u, \theta_u)\), is drawn as follows:

>>> g, kappa, theta, r = gt.generate_s1(300, beta=3, gamma=2.5,
...                                     average_degree=6, hyperbolic=True)
>>> pos = g.new_vp("vector<double>",
...                vals=np.array([r.a * np.cos(theta.a),
...                               r.a * np.sin(theta.a)]).T)
>>> gt.graph_draw(g, pos=pos,
...               output="generate_s1-hyperbolic.pdf")
<...>
../_images/generate_s1-hyperbolic.png

\(\mathbb{S}^1\) graph with \(N=300\), \(\beta=3\), \(\gamma=2.5\), and average degree 6, with the vertices placed at their coordinates in the hyperbolic plane \(\mathbb{H}^2\), the radial coordinate \(r_u\) as the distance from the center.#