
    h                         S r SSKrSSKJr  SS/r\" S5      \" S5      \R                  " SS	9SS
 j5       5       5       r\R                  " SSS9S 5       rg)zTFunctions related to the Mycielski Operation and the Mycielskian family
of graphs.

    N)not_implemented_formycielskianmycielski_graphdirected
multigraphT)returns_graphc                   ^ [         R                  " U 5      n[        U5       H  nUR                  5       mUR	                  [        TST-  5      5        [        UR                  5       5      nUR                  U4S jU 5       5        UR                  U4S jU 5       5        UR                  ST-  5        UR                  U4S j[        T5       5       5        M     U$ )a  Returns the Mycielskian of a simple, undirected graph G

The Mycielskian of graph preserves a graph's triangle free
property while increasing the chromatic number by 1.

The Mycielski Operation on a graph, :math:`G=(V, E)`, constructs a new
graph with :math:`2|V| + 1` nodes and :math:`3|E| + |V|` edges.

The construction is as follows:

Let :math:`V = {0, ..., n-1}`. Construct another vertex set
:math:`U = {n, ..., 2n}` and a vertex, `w`.
Construct a new graph, `M`, with vertices :math:`U \bigcup V \bigcup w`.
For edges, :math:`(u, v) \in E` add edges :math:`(u, v), (u, v + n)`, and
:math:`(u + n, v)` to M. Finally, for all vertices :math:`u \in U`, add
edge :math:`(u, w)` to M.

The Mycielski Operation can be done multiple times by repeating the above
process iteratively.

More information can be found at https://en.wikipedia.org/wiki/Mycielskian

Parameters
----------
G : graph
    A simple, undirected NetworkX graph
iterations : int
    The number of iterations of the Mycielski operation to
    perform on G. Defaults to 1. Must be a non-negative integer.

Returns
-------
M : graph
    The Mycielskian of G after the specified number of iterations.

Notes
-----
Graph, node, and edge data are not necessarily propagated to the new graph.

   c              3   4   >#    U  H  u  pXT-   4v   M     g 7fN .0uvns      O/var/www/html/env/lib/python3.13/site-packages/networkx/generators/mycielski.py	<genexpr>mycielskian.<locals>.<genexpr>?   s     :	!U	s   c              3   6   >#    U  H  u  pUT-   U4v   M     g 7fr   r   r   s      r   r   r   @   s     :	!a%	   c              3   6   >#    U  H  oT-   S T-  4v   M     g7f)r
   Nr   )r   r   r   s     r   r   r   B   s     :Aa%Qr   )	nxconvert_node_labels_to_integersrangenumber_of_nodesadd_nodes_fromlistedgesadd_edges_fromadd_node)G
iterationsMi	old_edgesr   s        @r   r   r      s    Z 	**1-A:	q!a%)O		:	::	:	::	

1q5	:q::  H    )graphsr   c                     U S:  a  [         R                  " S5      eU S:X  a  [         R                  " S5      $ [        [         R                  " S5      U S-
  5      $ )a/  Generator for the n_th Mycielski Graph.

The Mycielski family of graphs is an infinite set of graphs.
:math:`M_1` is the singleton graph, :math:`M_2` is two vertices with an
edge, and, for :math:`i > 2`, :math:`M_i` is the Mycielskian of
:math:`M_{i-1}`.

More information can be found at
http://mathworld.wolfram.com/MycielskiGraph.html

Parameters
----------
n : int
    The desired Mycielski Graph.

Returns
-------
M : graph
    The n_th Mycielski Graph

Notes
-----
The first graph in the Mycielski sequence is the singleton graph.
The Mycielskian of this graph is not the :math:`P_2` graph, but rather the
:math:`P_2` graph with an extra, isolated vertex. The second Mycielski
graph is the :math:`P_2` graph, so the first two are hard coded.
The remaining graphs are generated using the Mycielski operation.

   zmust satisfy n >= 1r
   )r   NetworkXErrorempty_graphr   
path_graph)r   s    r   r   r   G   sP    @ 	1u455Av~~a   2==+QU33r'   )r*   )	__doc__networkxr   networkx.utilsr   __all___dispatchabler   r   r   r'   r   <module>r3      sx   
  .+
, Z \"%5 & # !5p T2&4 3&4r'   