+
    �°³jü  ã                   ó<  € 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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 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   zŠMechanism 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   &&Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/flow/utils.pyÚ__init__ÚCurrentEdge.__init__   s   € ØŒØ�;�;ˆ;Ø�L‰LŽNñ ó    c                ó   € V P                   # r   )Ú_curr©r   s   &r   ÚgetÚCurrentEdge.get   s   € Ø�z‰zÐ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   € ð	Ü˜dŸh™h›ˆDŽJøÜô 	Ø�L‰LŒNØð	ú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   € Ü˜˜g tÓ,¨d¯k©kÐ:Ü�U˜G TÓ*¨E¯L©LÐ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   € ß,0˜1�5 Dž.´e¸E³lˆŒØˆŽ
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   € Ø�z‰z˜TŸ_™_Ñ,Ð,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_graphÚpreserve_edge_attrsc           
     ón  a	€ V P                  4       '       d   \        P                  ! R4      h\        P                  ! 4       pRVn        VP                  V 4       \        W4      pV P                  RR7       UUUu. uF*  w  r4pW48w  g   K  V! W4V4      ;pf   K  V^ 8”  g   K&  W4V3NK,  	  pppp\        R4      o	^\        V	3R lV 4       4      ,          ;'       g    ^o	V P                  4       '       dk   V Fc  w  r4p\        VS	4      pVP                  W44      '       g)   VP                  W4VR7       VP                  WC^ R7       KQ  W‚V,          V,          R&   Ke  	  M>V F8  w  r4p\        VS	4      pVP                  W4VR7       VP                  WCVR7       K:  	  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).NT)Údatar7   c              3   ó>   <"  € T F  w  rq3S8w  g   K  Vx € K  	  R # 5ir   © )Ú.0ÚuÚvÚcapr7   s   &   €r   Ú	<genexpr>Ú)build_residual_network.<locals>.<genexpr>†   s   øé € Ð?¡y™)˜! ¸3±J—#’#£yùs   ƒ“
)rK   rK   )Úis_multigraphÚnxÚNetworkXErrorÚDiGraphÚ__networkx_cache__Úadd_nodes_fromÚ_capacity_functionr   r8   ÚsumÚis_directedÚminÚhas_edgeÚadd_edgeÚgraph)
ÚGrK   ÚRrT   rU   ÚattrrV   Ú	edge_listÚrr7   s
   &&       @r   Úbuild_residual_networkrk   P   s�  ø€ ð8 	‡�×ÒÜ×ÒÐQÓRÐRä
�
Š
‹€AØ€AÔØ×Ñ�QÔä! !Ó.€Hð Ÿ'™' t˜'Ô,õá,‰JˆA�$Ø‰6ô 	á& q¨TÓ2Ð2�sô 	àDGÈ!ÁGô 	ˆˆs‹Ù,ð ò ô  �‹,€CØ
ŒcÔ?¡yÓ?Ó?Õ
?×
DÐ
DÀ1€CØ‡}�}‡‚Û"‰IˆA�#Ü�C˜“ˆAØ—:‘:˜a×#Ò#ð —
‘
˜1¨!�
Ô,Ø—
‘
˜1¨!�
Ö,ð '(�!•�Q•˜
Ó#ò #ó #‰IˆA�#ä�C˜“ˆAØ�J‰J�q aˆJÔ(Ø�J‰J�q aˆJÖ(ñ	 #ð €A‡G�GˆE�Nà€HùôOs   Á<F0Â
F0ÂF0Â$F0rg   )ÚgraphsrN   Ú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   re   Úpopleftr   rZ   ÚNetworkXUnboundedÚaddÚappend)	rg   ÚsÚtÚqÚseenr7   rT   rU   rh   s	   &&&      r   Údetect_unboundednessrw   Ÿ   sŽ   € ô 	ˆqˆc‹
€AØˆ3€DØ
�'‰'�%�.€Cß
Ø�I‰I‹KˆØ•t—z‘z–|‰GˆAØ�JÕ 3Ö&¨1®=Ø”6Ü×.Ò.ØGóð ð —‘˜”Ø—‘˜–ó $ñ r   rf   Úflow)rl   rN   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)rx   NrR   )rS   rU   rh   s   &  r   rW   Ú"build_flow_dict.<locals>.<genexpr>»   s*   é € ð 
Ù-9¡' !¸TÀ&½\ÈAÑ=MÔˆQ�V•Õ«\ùs   ‚+™+)Úupdater   )rf   rg   Ú	flow_dictrT   rU   s   &&   r   Úbuild_flow_dictr~   µ   s_   € ð €IÛˆØ&'¦dÓ+¡d ˜1š¡dÑ+ˆ	‰Ø�×Ññ 
Ø-.­T¯Z©Z¬\ó
ö 	
ñ ð
 Ðùò	 ,s   ’Ac                óP   aa€ \        R4      o\        S4      '       d   S# VV3R l# )a  Returns a callable that returns the capacity of an edge.

Parameters
----------
G : NetworkX graph
    MultiGraph and MultiDiGraph are not supported.

capacity : string or callable
    If callable, the callable is returned unchanged. For it to work
    it must accept exactly three positional arguments
    ``(u, v, edge_attrs)``, where `u` and `v` are the endpoints of
    an edge and ``edge_attrs`` is the corresponding edge attribute
    dictionary. The callable must return either None (to hide an edge)
    or a number representing the capacity.

    If string, it is interpreted as the key of an edge attribute storing
    the capacity. In this case, a new callable is returned that accepts
    ``(u, v, edge_attrs)`` and returns ``edge_attrs[capacity]``.

Returns
-------
callable
    A callable with signature ``(u, v, edge_attrs)`` that returns the
    capacity of the edge joining nodes `u` and `v`.

Notes
-----
If `capacity` is a string and the specified attribute is not present on
an edge, that edge is assumed to have infinite capacity.
r7   c                 ó(   <€ VP                  SS4      # r   )r   )rT   rU   rP   rK   r7   s   &&&€€r   Ú<lambda>Ú$_capacity_function.<locals>.<lambda>ç   s   ø€ ˜dŸh™h x°Ô5r   )r8   Úcallable)rf   rK   r7   s   &f@r   r_   r_   Á   s'   ù€ ô@ �‹,€CÜ�×ÒØˆõ 6Ð5r   )r   r   r   rk   rw   r~   )r)   Úcollectionsr   ÚnetworkxrZ   Ú__all__r   r   r   Ú_dispatchabler8   rk   rw   r~   r_   rR   r   r   Ú<module>rˆ      sÚ   ðñõ ã ò€÷
ñ 
÷@ñ ÷ñ ð& ×ÒØ™E %›LÐ)¸ÐSWôñIóðIðX ×ÒØØ˜z©5°«<Ð8Ð9Øôñ
óð
ð" ×Ò˜#˜q # qÐ)ÀÀfÈdÀ^Ð?TÔUñó Vðô&6r   