+
    )i                         R t ^ RIt^ RIHt . R
Ot]P                  R 4       t]! R4      ]P                  R 4       4       t]! R4      ]! R4      ]P                  ! RRR7      RR	 l4       4       4       t	R# )z5Functions for computing and verifying regular graphs.N)not_implemented_forc                T  aaa \        V 4      ^ 8X  d   \        P                  ! R4      h\        P                  P	                  V 4      pV P                  4       '       g`   V P                  V4      o\        ;QJ d)    V3R lV P                   4       F  '       d   K   R# 	  R# ! V3R lV P                   4       4      # V P                  V4      oV3R lV P                   4       pV P                  V4      oV3R lV P                   4       p\        V4      ;'       d    \        V4      # )a  Determines whether a graph is regular.

A regular graph is a graph where all nodes have the same degree. A regular
digraph is a graph where all nodes have the same indegree and all nodes
have the same outdegree.

Parameters
----------
G : NetworkX graph

Returns
-------
bool
    Whether the given graph or digraph is regular.

Examples
--------
>>> G = nx.DiGraph([(1, 2), (2, 3), (3, 4), (4, 1)])
>>> nx.is_regular(G)
True

zGraph has no nodes.c              3   2   <"   T F  w  rSV8H  x  K  	  R # 5iN ).0_dd1s   &  Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/algorithms/regular.py	<genexpr>is_regular.<locals>.<genexpr>&   s     0xtq27x   FTc              3   2   <"   T F  w  rSV8H  x  K  	  R # 5ir   r   )r   r   r	   d_ins   &  r   r   r   )   s     8KDAdaiKr   c              3   2   <"   T F  w  rSV8H  x  K  	  R # 5ir   r   )r   r   r	   d_outs   &  r   r   r   +   s     ;ldauzlr   )
lennxNetworkXPointlessConceptutilsarbitrary_elementis_directeddegreeall	in_degree
out_degree)Gn1
in_regularout_regularr
   r   r   s   &   @@@r   
is_regularr!   	   s    0 1v{))*?@@		#	#A	&B==??XXb\s0qxx0ss0s0s0qxx000{{28AKK8
R ;all;:333{#33    directedc                   a \         ;QJ d)    V3R lV P                   4       F  '       d   K   R# 	  R# ! V3R lV P                   4       4      # )aJ  Determines whether the graph ``G`` is a k-regular graph.

A k-regular graph is a graph where each vertex has degree k.

Parameters
----------
G : NetworkX graph

Returns
-------
bool
    Whether the given graph is k-regular.

Examples
--------
>>> G = nx.Graph([(1, 2), (2, 3), (3, 4), (4, 1)])
>>> nx.is_k_regular(G, k=3)
False

c              3   2   <"   T F  w  rVS8H  x  K  	  R # 5ir   r   )r   nr	   ks   &  r   r   is_k_regular.<locals>.<genexpr>F   s     +($!qAv(r   FT)r   r   )r   r'   s   &fr   is_k_regularr)   /   s6    . 3+!((+33+3+3+!((+++r"   
multigraphT)preserve_edge_attrsreturns_graphc                  aaaaa \         ;QJ d)    V3R lV P                   4       F  '       g   K   RM	  RM! V3R lV P                   4       4      '       d   \        P                  ! R4      hV P	                  4       p. pV P                   EFU  w  rVSVR,          8  o\        V4       Uu. uF  quV3NK  	  upoS'       d.   \        V^V,          S,
          4       Uu. uF  quV3NK  	  pp. oMU\        ^V,          ^V,          S,           4       Uu. uF  quV3NK  	  pp\        V^V,          4       Uu. uF  quV3NK  	  upoVP                  \        SS4      4       \        SW5,          P                  4       4       F  w  p	w  rVP                  ! W3/ VB  K  	  VP                  VVV3R lV 4       4       VP                  V4       VP                  VSVS34       EKX  	  \        P                  ! VRVR7      o\        P                  ! VS4      '       g   \        P                  ! R4      hVP                  V3R	 lVP                   4       4       V F  w  popoVP!                  V4       \#        V4      pS FI  p	VP$                  V	,          P                  4        F!  w  rW9  g   K  VP                  ! WZ3/ VB   KG  	  KK  	  VP'                  SV,           S,           4       K  	  V# u upi u upi u upi u upi )
u  Compute a `k`-factor of a graph.

A `k`-factor of a graph is a spanning `k`-regular subgraph.
A spanning `k`-regular subgraph of `G` is a subgraph that contains
each node of `G` and a subset of the edges of `G` such that each
node has degree `k`.

Parameters
----------
G : NetworkX graph
    An undirected graph.

k : int
    The degree of the `k`-factor.

matching_weight: string, optional (default="weight")
    Edge attribute name corresponding to the edge weight.
    If not present, the edge is assumed to have weight 1.
    Used for finding the max-weighted perfect matching.

Returns
-------
NetworkX graph
    A `k`-factor of `G`.

Examples
--------
>>> G = nx.Graph([(1, 2), (2, 3), (3, 4), (4, 1)])
>>> KF = nx.k_factor(G, k=1)
>>> KF.edges()
EdgeView([(1, 2), (3, 4)])

References
----------
.. [1] "An algorithm for computing simple k-factors.",
   Meijer, Henk, Yurai Núñez-Rodríguez, and David Rappaport,
   Information processing letters, 2009.
c              3   2   <"   T F  w  rVS8  x  K  	  R # 5ir   r   )r   r   r	   r'   s   &  r   r   k_factor.<locals>.<genexpr>t   s     
&XTQ1q5Xr   TFz/Graph contains a vertex with degree less than kg       @c              3   P   <"   T F  pS'       d   SMS F  q!V3x  K
  	  K  	  R # 5ir   r   )r   uvinneris_largeouters   &  r   r   r/      s#     VAu8T!Q8Ts   &&)maxcardinalityweightz7Cannot find k-factor because no perfect matching existsc              3   ^   <"   T F"  qS9  g   K  VR R R1,          S9  g   K  Vx  K$  	  R # 5i)Nr   )r   ems   & r   r   r/      s(     N7aqjQttWA=M7s   --
-)anyr   r   NetworkXUnfeasiblecopyrangeadd_edges_fromzipitemsadd_edgeremove_nodeappendmax_weight_matchingis_perfect_matchingremove_edges_fromedgesadd_nodeset_adjremove_nodes_from)r   r'   matching_weightggadgetsnoder   icoreouter_nneighborattrscore_setr3   r4   r;   r5   s   &f&          @@@@r   k_factorrX   I   s   V s
&QXX
&sss
&QXX
&&&##$UVV	AG $ %*&M2MqM2',VQZ!^'DE'D!1I'DDEE',QZVa'HI'H!1I'HDI(-fa&j(AB(A1AY(ABE 	
UE*+*-eQW]]_*E&G&hJJw2E2 +F 	
VVV	deT512+ !0 	qoNA!!!Q''##E
 	

 N177NN %, eT5	

4t9G#$66'?#8#8#:+JJt77 $; 
 	
EDL501 %, HQ 3E JBs   -K3 K8K=7L)r!   r)   rX   )r7   )
__doc__networkxr   networkx.utilsr   __all___dispatchabler!   r)   rX   r   r"   r   <module>r^      s    ;  .
4 "4 "4J Z ,  !,0 Z \"d$?[ @ # ![r"   