generate_k_lift#
- graph_tool.generation.generate_k_lift(g, k)[git][source]#
Generate a random \(k\)-lift of a graph.
- Parameters:
- g
Graph Base graph.
- k
int Number of copies of every vertex.
- g
- Returns:
- h
Graph The lifted graph, where vertex \(ik + a\) is the copy \(a\) of vertex \(i\) of
g.
- h
See also
generate_regular_expanderRandom regular expanders
graph_tool.structure.is_regular_expanderSpectral 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") <...>
Random 3-lift of the complete graph \(K_4\). The vertex colors indicate the vertices of \(K_4\) of which they are copies.#