+
    )if                     4   R t ^ RIHt ^ RIt. ROt ! R R4      t ! R R4      t ! R R4      t]P                  ! R	]
! R
4      /RR7      R 4       t]P                  ! RRR	]
! R
4      //RR7      R 4       t]P                  ! R^ R^/RRR//R7      R 4       tR# )z<
Utility classes and functions for network flow algorithms.
)dequeNCurrentEdgeLevelGlobalRelabelThresholdc                   F   a  ] tR t^t o RtR	tR tR tR tR t	R t
RtV tR# )
r   zMechanism for iterating over out-edges incident to a node in a circular
manner. StopIteration exception is raised when wraparound occurs.
c                Z    Wn         V P                   '       d   V P                  4        R # R # N)_edges_rewind)selfedgess   &&\/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/algorithms/flow/utils.py__init__CurrentEdge.__init__   s    ;;;LLN     c                    V P                   # r   )_currr   s   &r   getCurrentEdge.get   s    zzr   c                |     \        V P                  4      V n        R #   \         d    T P	                  4        h i ; ir   )next_itr   StopIterationr
   r   s   &r   move_to_nextCurrentEdge.move_to_next"   s1    	dhhDJ 	LLN	s    ;c                    \        V P                  P                  4       4      V n        \	        V P                  4      V n        R # r   )iterr	   itemsr   r   r   r   s   &r   r
   CurrentEdge._rewind)   s*    ))+,$((^
r   c                h    \        V R R4      V P                  3\        VR R4      VP                  38H  # )r   N)getattrr	   )r   others   &&r   __eq__CurrentEdge.__eq__-   s6    gt,dkk:UGT*ELL9
 	
r   )r   r	   r   N)r	   r   r   )__name__
__module____qualname____firstlineno____doc__	__slots__r   r   r   r
   r#   __static_attributes____classdictcell____classdict__s   @r   r   r      s/      +I
$
 
r   c                   .   a  ] tR t^3t o RtRtR tRtV tR# )r   z%Active and inactive nodes in a level.c                B    \        4       V n        \        4       V n        R # r   )setactiveinactiver   s   &r   r   Level.__init__8   s    er   )r2   r3   N)	r%   r&   r'   r(   r)   r*   r   r+   r,   r-   s   @r   r   r   3   s     /&I r   c                   <   a  ] tR t^=t o RtR tR tR tR tRt	V t
R# )r   zNMeasurement of work before the global relabeling heuristic should be
applied.
c                b    V'       d   W,           V,          M
\        R 4      V n        ^ V n        R# )infN)float
_threshold_work)r   nmfreqs   &&&&r   r   GlobalRelabelThreshold.__init__B   s    ,015D.eEl
r   c                8    V ;P                   V,          un         R # r   r:   )r   works   &&r   add_workGlobalRelabelThreshold.add_workF   s    

d
r   c                4    V P                   V P                  8  # r   )r:   r9   r   s   &r   
is_reached!GlobalRelabelThreshold.is_reachedI   s    zzT__,,r   c                    ^ V n         R# )    Nr@   r   s   &r   
clear_work!GlobalRelabelThreshold.clear_workL   s	    
r   )r9   r:   N)r%   r&   r'   r(   r)   r   rB   rE   rI   r+   r,   r-   s   @r   r   r   =   s#     - r   capacityr7   T)
edge_attrsreturns_graphc           	       aa V P                  4       '       d   \        P                  ! R4      h\        P                  ! 4       pRVn        VP                  V 4       \        R4      oV P                  RR7       UUUu. uF+  w  r4pW48w  g   K  VP                  SS4      ^ 8  g   K'  W4V3NK-  	  pppp^\        VV3R lV 4       4      ,          ;'       g    ^oV P                  4       '       d{   V Fs  w  r4p\        VP                  SS4      S4      pVP                  W44      '       g)   VP                  W4VR7       VP                  WC^ R7       Ka  WrV,          V,          R&   Ku  	  MNV FH  w  r4p\        VP                  SS4      S4      pVP                  W4VR7       VP                  WCVR7       KJ  	  SVP                  R&   V# u upppi )	a  Build a residual network and initialize a zero flow.

The residual network :samp:`R` from an input graph :samp:`G` has the
same nodes as :samp:`G`. :samp:`R` is a DiGraph that contains a pair
of edges :samp:`(u, v)` and :samp:`(v, u)` iff :samp:`(u, v)` is not a
self-loop, and at least one of :samp:`(u, v)` and :samp:`(v, u)` exists
in :samp:`G`.

For each edge :samp:`(u, v)` in :samp:`R`, :samp:`R[u][v]['capacity']`
is equal to the capacity of :samp:`(u, v)` in :samp:`G` if it exists
in :samp:`G` or zero otherwise. If the capacity is infinite,
:samp:`R[u][v]['capacity']` will have a high arbitrary finite value
that does not affect the solution of the problem. This value is stored in
:samp:`R.graph['inf']`. For each edge :samp:`(u, v)` in :samp:`R`,
:samp:`R[u][v]['flow']` represents the flow function of :samp:`(u, v)` and
satisfies :samp:`R[u][v]['flow'] == -R[v][u]['flow']`.

The flow value, defined as the total flow into :samp:`t`, the sink, is
stored in :samp:`R.graph['flow_value']`. If :samp:`cutoff` is not
specified, reachability to :samp:`t` using only edges :samp:`(u, v)` such
that :samp:`R[u][v]['flow'] < R[u][v]['capacity']` induces a minimum
:samp:`s`-:samp:`t` cut.

z0MultiGraph and MultiDiGraph not supported (yet).Nr7   T)datac              3   n   <"   T F*  w  rpSV9   g   K  VS,          S8w  g   K  VS,          x  K,  	  R # 5ir    ).0uvattrrK   r7   s   &   r   	<genexpr>)build_residual_network.<locals>.<genexpr>   s=      
'
d4 $(Nc$9 DNN's   555)rK   rK   )is_multigraphnxNetworkXErrorDiGraph__networkx_cache__add_nodes_fromr8   r   r   sumis_directedminhas_edgeadd_edgegraph)	GrK   RrS   rT   rU   	edge_listrr7   s	   &f      @r   build_residual_networkrh   P   s   4 	QRR


AAQ
,C ''t',,JA$6 	hhx-1 	t,    	

 
'
 
	
 	 	   	}}#JA$DHHXs+S1A::a## 

1!
,

1!
, '(!Q
# $ $JA$DHHXs+S1AJJqaJ(JJqaJ(	 $ AGGENH[s   =GG&Gre   )graphspreserve_edge_attrspreserve_graph_attrsc                h   \        V.4      pV0pV P                  R,          pV'       d   VP                  4       pW,          P                  4        F[  w  rxVR,          V8X  g   K  Wt9  g   K  Wr8X  d   \        P
                  ! R4      hVP                  V4       VP                  V4       K]  	  K  R# )z*Detect an infinite-capacity s-t path in R.r7   rK   z-Infinite capacity path, flow unbounded above.N)r   rc   popleftr   rY   NetworkXUnboundedaddappend)	re   stqseenr7   rS   rT   rU   s	   &&&      r   detect_unboundednessru      s     	qc
A3D
''%.C
IIKtzz|GAJ3&1=6..G   $ r   rd   flow)ri   rj   c                    / pV  FO  pW,           Uu/ uF  qD^ bK  	  upW#&   W#,          P                  R W,          P                  4        4       4       KQ  	  V# u upi )z0Build a flow dictionary from a residual network.c              3   Z   "   T F!  w  rVR ,          ^ 8  g   K  WR ,          3x  K#  	  R# 5i)rv   NrQ   )rR   rT   rU   s   &  r   rV   "build_flow_dict.<locals>.<genexpr>   s*      
-9'!T&\A=MQV\s   ++)updater   )rd   re   	flow_dictrS   rT   s   &&   r   build_flow_dictr|      s_     I&'d+d1d+	 
-.TZZ\
 	
 
 	 ,s   A)r   r   r   rh   ru   r|   )r)   collectionsr   networkxrY   __all__r   r   r   _dispatchabler8   rh   ru   r|   rQ   r   r   <module>r      s     
 
@  & j%,7tLO MOd z5<89

" #q#q)fd^?TU Vr   