+
    �°³jO*  ã                   ó�   € R t ^ RIHt ^ RIt^RIHt ^RIHtH	t	 R.t
R t]P                  ! R]! R4      /R	R	R
7      RR l4       tR# )z?
Shortest augmenting path algorithm for maximum flow problems.
)ÚdequeN)Úedmonds_karp_core)ÚCurrentEdgeÚbuild_residual_networkÚshortest_augmenting_pathc                ó¢  aaaa€ W9  d$   \         P                  ! R\        V4       R24      hW 9  d$   \         P                  ! R\        V4       R24      hW8X  d   \         P                  ! R4      hVf   \        W4      pMTpVP                  oVP
                  pVP                  oV F&  p	SV	,          P                  4        F  p
^ V
R&   K
  	  K(  	  V^ /p\        V^ 3.4      pV'       dr   VP                  4       w  r�V^,          pW‰,          P                  4        F:  w  rïWë9  g   K  VR,          VR,          8  g   K$  WÛV&   VP                  Wí34       K<  	  Ky  W9  d   ^ VP                  R&   V# \        V 4      oVP                  4       ^,          pV F9  p	W›9   d	   W¹,          MSSV	,          R&   \        SV	,          4      SV	,          R&   K;  	  ^ .^S,          ^,
          ,          pV F&  p	VSV	,          R,          ;;,          ^,          uu&   K(  	  VP                  R	,          oVV3R
 lpVVV3R lpVf   \!        R	4      p^ pV.pTp	V'       g   SM)\#        \%        VR,          ^SR,          ,          4      4      pSV,          R,          V8¬  pV'       gÂ   SV	,          R,          pSV	,          R,          p VP'                  4       w  rïVSV,          R,          ^,           8X  d*   VR,          VR,          8  d   VP                  V4       Tp	M VP)                  4        Kk  W’8X  g   K›  VV! V4      ,          pVV8¼  d   VVP                  R&   V# V.pTp	KÉ  V\/        WqW&V,
          4      ,          pVVP                  R&   V#   \*         dµ    TT;;,          ^,          uu&   TT,          ^ 8X  d   TTP                  R&   Tu # T! T	4      pY‘8X  d(   TT8¼  d!   T'       g   TTP                  R&   Tu # Rp K×  TT;;,          ^,          uu&   TST	,          R&   Y‘8w  d   TP-                  4        TR,          p	 EK   EKŠ  i ; i)z9Implementation of the shortest augmenting path algorithm.znode z not in graphz!source and sink are the same nodeÚflowÚcapacityÚ
flow_valueÚheightÚ	curr_edgeÚinfc                óÄ  <€ Sp\        V 4      p\        V4      pV F5  pSV,          V,          p\        WR,          VR,          ,
          4      pTpK7  	  V^,          S8”  d   \        P                  ! R4      h\        V 4      p\        V4      pV FK  pSV,          V,          R;;,          V,          uu&   SV,          V,          R;;,          V,          uu&   TpKM  	  V# )z&Augment flow along a path from s to t.r	   r   z-Infinite capacity path, flow unbounded above.)ÚiterÚnextÚminÚnxÚNetworkXUnbounded)Úpathr   ÚitÚuÚvÚattrÚR_succr   s   &     €€Úp/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/flow/shortestaugmentingpath.pyÚaugmentÚ.shortest_augmenting_path_impl.<locals>.augmentF   sÇ   ø€ ð ˆÜ�$‹ZˆÜ�‹HˆÛˆAØ˜!•9˜Q•<ˆDÜ�t *Õ-°°VµÕ<Ó=ˆDØŠAñ ð �!�8�cŒ>Ü×&Ò&Ð'VÓWÐWä�$‹ZˆÜ�‹HˆÛˆAØ�1�I�a�L˜×  DÕ(Ó Ø�1�I�a�L˜×  DÕ(Ó ØŠAñ ð ˆó    c                óÊ   <€ S^,
          pSV ,          P                  4        F6  w  r#VR,          VR,          8  g   K  \        VSV,          R,          4      pK8  	  V^,           # )z,Relabel a node to create an admissible edge.r   r	   r   )Úitemsr   )r   r   r   r   ÚR_nodesr   Úns   &   €€€r   ÚrelabelÚ.shortest_augmenting_path_impl.<locals>.relabel[   sU   ø€ à�Q•ˆØ˜a•y—‘Ö(‰GˆAØ�F�|˜d :Õ.Ö.Ü˜V W¨Q¥Z°Õ%9Ó:’ñ )ð ˜�zÐr   g      à?TgUUUUUUå?éÿÿÿÿ)r   ÚNetworkXErrorÚstrr   ÚnodesÚpredÚsuccÚvaluesr   Úpopleftr   ÚappendÚgraphÚlenÚsizer   ÚfloatÚintr   ÚgetÚmove_to_nextÚStopIterationÚpopr   )ÚGÚsÚtr	   ÚresidualÚ	two_phaseÚcutoffÚRÚR_predr   ÚeÚheightsÚqr   r   r   ÚmÚcountsr   r"   r
   r   ÚdÚdoner   r    r   r   r!   s   &&&&&&&                  @@@@r   Úshortest_augmenting_path_implrE      sÞ  û€ à„zÜ×Ò ¤s¨1£v h¨mÐ<Ó=Ð=Ø„zÜ×Ò ¤s¨1£v h¨mÐ<Ó=Ð=Ø„vÜ×ÒÐBÓCÐCàÒÜ" 1Ó/‰àˆà�g‰g€GØ�V‰V€FØ�V‰V€Fó ˆØ˜•×!Ñ!Ö#ˆAØˆAˆf‹Ió $ñ ð
 �!ˆf€GÜ��1ˆvˆh‹€Aß
Ø—I‘I“K‰	ˆØ�!�ˆØ•y—‘Ö(‰GˆAØÖ D¨¥L°4¸
Õ3CÖ$CØ#˜‘
Ø—‘˜!˜Ö%ó )ð
 	Ôð !"ˆ�‰�ÑØˆäˆA‹€AØ	�‰‹�1�€Aó ˆØ-.¬\˜wžz¸qˆ��
�8ÑÜ"-¨f°Q­iÓ"8ˆ��
�;Óñ ð
 ˆS�A˜•E˜A•IÕ€FÛˆØˆw�q�z˜(Õ#×$¨Õ)Õ$ñ ð �'‰'�%�.€Cö÷*ð ‚~Ü�u“ˆð €JØˆ3€DØ	€Aß‰¤¤C¨¨3­°°A¸'µNÕ0BÓ$CÓ D€AØ�1�:�hÕ 1Ñ$€DßØ˜•˜HÕ%ˆØ˜A•J˜{Õ+ˆ	àØ—m‘m“o‰GˆAØ˜ � HÕ-°Õ1Ô1°d¸6µlÀTÈ*ÕEUÔ6Uà—‘˜A”Ø�ØðØ×&Ñ&Ö(ð8 Ž6ð ™' $›-Õ'ˆJØ˜VÔ#Ø(2�—‘˜Ñ%Ø�Ø�3ˆDØŠAð Ô# A¨!°jÕ-@ÓAÕA€Jà&€A‡G�GˆLÑØ€HøôS !ô Ø�v— !Õ#“Ø˜&•> QÔ&ð -7�A—G‘G˜LÑ)Ø’HÙ  ›�Ø”6˜f¨œkß$ð 1;˜Ÿ™ Ñ-Ø šð  $˜ÚØ�v— !Õ#“Ø'-�˜•
˜8Ñ$Ø”6ð —H‘H”JØ˜R��AÛó ð+ús+   ÌN Î?QÏQÏ-QÐ QÐA QÑQr	   r   T)Ú
edge_attrsÚreturns_graphÚpreserve_edge_attrsc           	     ól   € \        WW#WFV4      pRVP                  R&   \        P                  ! V4       V# )aÊ  Find a maximum single-commodity flow using the shortest augmenting path
algorithm.

This function returns the residual network resulting after computing
the maximum flow. See below for details about the conventions
NetworkX uses for defining residual networks.

This algorithm has a running time of $O(n^2 m)$ for $n$ nodes and $m$
edges.


Parameters
----------
G : NetworkX graph
    Edges of the graph are expected to have an attribute called
    'capacity'. If this attribute is not present, the edge is
    considered to have infinite capacity.

s : node
    Source node for the flow.

t : node
    Sink node for the flow.

capacity : string or function (default= 'capacity')
    If this is a string, then edge capacity will be accessed via the
    edge attribute with this key (that is, the capacity of the edge
    joining `u` to `v` will be ``G.edges[u, v][capacity]``). If no
    such edge attribute exists, the capacity of the edge is assumed to
    be infinite.

    If this is a function, the capacity of an edge is the value
    returned by the function. The function must accept exactly three
    positional arguments: the two endpoints of an edge and the
    dictionary of edge attributes for that edge. The function must
    return a number or None to indicate a hidden edge.

residual : NetworkX graph
    Residual network on which the algorithm is to be executed. If None, a
    new residual network is created. Default value: None.

value_only : bool
    If True compute only the value of the maximum flow. This parameter
    will be ignored by this algorithm because it is not applicable.

two_phase : bool
    If True, a two-phase variant is used. The two-phase variant improves
    the running time on unit-capacity networks from $O(nm)$ to
    $O(\min(n^{2/3}, m^{1/2}) m)$. Default value: False.

cutoff : integer, float
    If specified, the algorithm will terminate when the flow value reaches
    or exceeds the cutoff. In this case, it may be unable to immediately
    determine a minimum cut. Default value: None.

Returns
-------
R : NetworkX DiGraph
    Residual network after computing the maximum flow.

Raises
------
NetworkXError
    The algorithm does not support MultiGraph and MultiDiGraph. If
    the input graph is an instance of one of these two classes, a
    NetworkXError is raised.

NetworkXUnbounded
    If the graph has a path of infinite capacity, the value of a
    feasible flow on the graph is unbounded above and the function
    raises a NetworkXUnbounded.

See also
--------
:meth:`maximum_flow`
:meth:`minimum_cut`
:meth:`edmonds_karp`
:meth:`preflow_push`

Notes
-----
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.

Examples
--------
>>> from networkx.algorithms.flow import shortest_augmenting_path

The functions that implement flow algorithms and output a residual
network, such as this one, are not imported to the base NetworkX
namespace, so you have to explicitly import them from the flow package.

>>> G = nx.DiGraph()
>>> G.add_edge("x", "a", capacity=3.0)
>>> G.add_edge("x", "b", capacity=1.0)
>>> G.add_edge("a", "c", capacity=3.0)
>>> G.add_edge("b", "c", capacity=5.0)
>>> G.add_edge("b", "d", capacity=4.0)
>>> G.add_edge("d", "e", capacity=2.0)
>>> G.add_edge("c", "y", capacity=2.0)
>>> G.add_edge("e", "y", capacity=3.0)
>>> R = shortest_augmenting_path(G, "x", "y")
>>> flow_value = nx.maximum_flow_value(G, "x", "y")
>>> flow_value
3.0
>>> flow_value == R.graph["flow_value"]
True

r   Ú	algorithm)rE   r-   r   Ú_clear_cache)	r6   r7   r8   r	   r9   Ú
value_onlyr:   r;   r<   s	   &&&&&&&& r   r   r   ¦   s4   € ôX 	& a¨A¸ÈfÓU€AØ5€A‡G�GˆKÑÜ‡O‚O�AÔØ€Hr   )r	   NFFN)Ú__doc__Úcollectionsr   Únetworkxr   Úedmondskarpr   Úutilsr   r   Ú__all__rE   Ú_dispatchabler0   r   © r   r   Ú<module>rU      sY   ðñõ ã å *ß 6à%Ð
&€òTðn ×ÒØ™E %›LÐ)¸ÐSWôóLóòLr   