generate_regular_expander#
- graph_tool.generation.generate_regular_expander(N, d, epsilon=0, max_tries=100)[git][source]#
Generate a random regular graph that is a (near-)Ramanujan expander.
- Parameters:
- N
int Number of vertices.
- d
int Degree, which must be even.
- epsilon
float(optional, default:0) Tolerance above the Ramanujan bound (see
is_regular_expander()).- max_tries
int(optional, default:100) Maximum number of attempts.
- N
- Returns:
- g
Graph The generated undirected \(d\)-regular graph.
- g
See also
graph_tool.structure.is_regular_expanderSpectral test for expanders
generate_k_liftRandom lifts of a graph
random_graphRandom graph with a given degree sequence
Notes
The graph is the union of \(d/2\) uniformly random Hamiltonian cycles, each redrawn until it shares no edge with the previous ones [friedman-proof-2008]. The graph is redrawn until it passes the test of
is_regular_expander(); by Friedman’s theorem, random regular graphs are near-Ramanujan with high probability, so that few attempts are needed for \(\epsilon > 0\). AValueErroris raised ifmax_triesattempts fail.References
[friedman-proof-2008]Joel Friedman, “A proof of Alon’s second eigenvalue conjecture and related problems”, Memoirs of the American Mathematical Society 195, 910 (2008), DOI: 10.1090/memo/0910 [sci-hub, @tor], arXiv: cs/0405020
Examples
>>> g = gt.generate_regular_expander(1000, 4, epsilon=0.1) >>> print(gt.is_regular_expander(g, epsilon=0.1)) True
A smaller instance is drawn as follows:
>>> g = gt.generate_regular_expander(30, 4, epsilon=0.5) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_regular_expander-small.pdf") <...>
Random 4-regular near-Ramanujan graph with \(N=30\) and \(\epsilon=0.5\).#