generate_k_lift

generate_k_lift#

graph_tool.generation.generate_k_lift(g, k)[git][source]#

Generate a random \(k\)-lift of a graph.

Parameters:
gGraph

Base graph.

kint

Number of copies of every vertex.

Returns:
hGraph

The lifted graph, where vertex \(ik + a\) is the copy \(a\) of vertex \(i\) of g.

See also

generate_regular_expander

Random regular expanders

graph_tool.structure.is_regular_expander

Spectral test for expanders

Notes

In a \(k\)-lift [amit-random-2002], every vertex \(i\) is replaced by \(k\) copies \((i, a)\), and every edge \((i, j)\) by the perfect matching \((i, a)\) – \((j, \pi_{ij}(a))\), where \(\pi_{ij}\) is a uniformly random permutation chosen independently for every edge. A lift of a \(d\)-regular graph is \(d\)-regular, and random lifts of good expanders are good expanders with high probability. The algorithm runs in time \(O(N k + E k\log k)\).

References

[amit-random-2002]

Alon Amit and Nathan Linial, “Random graph coverings I: General theory and graph connectivity”, Combinatorica 22, 1-18 (2002), DOI: 10.1007/s004930200000 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> h = gt.generate_k_lift(g, 3)
>>> print(h.num_vertices(), h.num_edges())
102 234

A 3-lift of the complete graph \(K_4\) is drawn as follows, with the copies of every vertex in the same color:

>>> h = gt.generate_k_lift(gt.complete_graph(4), 3)
>>> b = h.new_vp("int", vals=np.arange(12) // 3)
>>> cmap = matplotlib.colors.ListedColormap(
...     ["#9bbedc", "#f28c8e", "#a6d7a4", "#cba6d1"])
>>> gt.graph_draw(h, pos=gt.sfdp_layout(h), vertex_fill_color=b, vcmap=cmap,
...               output="generate_k_lift-k4.pdf")
<...>
../_images/generate_k_lift-k4.png

Random 3-lift of the complete graph \(K_4\). The vertex colors indicate the vertices of \(K_4\) of which they are copies.#