ó ŸÃÒYc@sFdZddlZddlZddgZdd„Zdd„ZdS(s5Provides explicit constructions of expander graphs. iÿÿÿÿNtmargulis_gabber_galil_graphtchordal_cycle_graphcCs1|dkrtjƒ}n1|jƒs4|jƒ rLd}tj|ƒ‚n|}|jƒx¸tjt |ƒddƒD]›\}}xŒ|d|||f|d|d||f||d||f||d|d|ffD](\}}|j ||f||fƒqçWqxWdj |ƒ|j d<|S(sÚReturn the Margulis-Gabber-Galil undirected MultiGraph on `n^2` nodes. The undirected MultiGraph is regular with degree `8`. Nodes are integer pairs. The second-largest eigenvalue of the adjacency matrix of the graph is at most `5 \sqrt{2}`, regardless of `n`. Parameters ---------- n : int Determines the number of nodes in the graph: `n^2`. create_using : graph-like A graph-like object that receives the constructed edges. If None, then a :class:`~networkx.MultiGraph` instance is used. Returns ------- G : graph The constructed undirected multigraph. Raises ------ NetworkXError If the graph is directed or not a multigraph. s0`create_using` must be an undirected multigraph.trepeatiis margulis_gabber_galil_graph({0})tnameN( tNonetnxt MultiGrapht is_directedt is_multigrapht NetworkXErrortcleart itertoolstproducttrangetadd_edgetformattgraph(tnt create_usingtmsgtGtxtytutv((ss/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/expanders.pyR.s  (1>$c Csû|dkrtjƒ}n1|jƒs4|jƒ rLd}tj|ƒ‚n|}|jƒx‚t|ƒD]t}|d|}|d|}|dkr­t||d|ƒnd}x'|||fD]}|j ||ƒqÃWqiWdj |ƒ|j d<|S(s'Return the chordal cycle graph on `p` nodes. The returned graph is a cycle graph on `p` nodes with chords joining each vertex `x` to its inverse modulo `p`. This graph is a (mildly explicit) 3-regular expander [1]_. `p` *must* be a prime number. Parameters ---------- p : a prime number The number of vertices in the graph. This also indicates where the chordal edges in the cycle will be created. create_using : graph-like A graph-like object that receives the constructed edges. If None, then a :class:`~networkx.MultiGraph` instance is used. Returns ------- G : graph The constructed undirected multigraph. Raises ------ NetworkXError If the graph provided in `create_using` is directed or not a multigraph. References ---------- .. [1] Theorem 4.4.2 in A. Lubotzky. "Discrete groups, expanding graphs and invariant measures", volume 125 of Progress in Mathematics. Birkhäuser Verlag, Basel, 1994. s0`create_using` must be an undirected multigraph.iiischordal_cycle_graph({0})RN( RRRRRR R R tpowRRR( tpRRRRtlefttrighttchordR((ss/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/expanders.pyRXs(   ((t__doc__R tnetworkxRt__all__RRR(((ss/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/expanders.pyts    # *