+
    )is(                     v    R t ^ RIHtHt ^ RIHt ^ RIt. R
Ot ! R R4      t	 ! R R]	4      t
 ! R	 R]	4      tR# )z
Min-heaps.
)heappopheappush)countNMinHeapPairingHeap
BinaryHeapc                   v   a  ] tR t^t o Rt ! R R4      tR tR tR tRR lt	RR	 lt
R
 tR tR tR tRtV tR# )r   zBase class for min-heaps.

A MinHeap stores a collection of key-value pairs ordered by their values.
It supports querying the minimum pair, inserting a new pair, decreasing the
value in an existing pair and deleting the minimum pair.
c                   4   a  ] tR t^t o RtRtR tR tRtV t	R# )MinHeap._Itemz2Used by subclassess to represent a key-value pair.c                    Wn         W n        R # Nkeyvalue)selfr   r   s   &&&R/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/utils/heaps.py__init__MinHeap._Item.__init__   s    HJ    c                D    \        V P                  V P                  34      # r   )reprr   r   r   s   &r   __repr__MinHeap._Item.__repr__   s    4::.//r   r   N)
__name__
__module____qualname____firstlineno____doc__	__slots__r   r   __static_attributes____classdictcell____classdict__s   @r   _Itemr
      s     @$			0 	0r   r$   c                    / V n         R# )zInitialize a new min-heap.N_dictr   s   &r   r   MinHeap.__init__!   s	    
r   c                    \         h)zQuery the minimum key-value pair.

Returns
-------
key, value : tuple
    The key-value pair with the minimum value in the heap.

Raises
------
NetworkXError
    If the heap is empty.
NotImplementedErrorr   s   &r   minMinHeap.min%   
     "!r   c                    \         h)zDelete the minimum pair in the heap.

Returns
-------
key, value : tuple
    The key-value pair with the minimum value in the heap.

Raises
------
NetworkXError
    If the heap is empty.
r*   r   s   &r   popMinHeap.pop4   r.   r   Nc                    \         h)a)  Returns the value associated with a key.

Parameters
----------
key : hashable object
    The key to be looked up.

default : object
    Default value to return if the key is not present in the heap.
    Default value: None.

Returns
-------
value : object.
    The value associated with the key.
r*   r   r   defaults   &&&r   getMinHeap.getC   s
    " "!r   c                    \         h)a  Insert a new key-value pair or modify the value in an existing
pair.

Parameters
----------
key : hashable object
    The key.

value : object comparable with existing values.
    The value.

allow_increase : bool
    Whether the value is allowed to increase. If False, attempts to
    increase an existing value have no effect. Default value: False.

Returns
-------
decreased : bool
    True if a pair is inserted or the existing value is decreased.
r*   )r   r   r   allow_increases   &&&&r   insertMinHeap.insertV   s
    * "!r   c                ,    \        V P                  4      # z"Returns whether the heap if empty.boolr'   r   s   &r   __nonzero__MinHeap.__nonzero__m       DJJr   c                ,    \        V P                  4      # r<   r=   r   s   &r   __bool__MinHeap.__bool__q   rA   r   c                ,    \        V P                  4      # )z2Returns the number of key-value pairs in the heap.)lenr'   r   s   &r   __len__MinHeap.__len__u   s    4::r   c                    WP                   9   # )zyReturns whether a key exists in the heap.

Parameters
----------
key : any hashable object.
    The key to be looked up.
r&   )r   r   s   &&r   __contains__MinHeap.__contains__y   s     jj  r   r&   r   F)r   r   r   r   r   r$   r   r,   r0   r5   r9   r?   rC   rG   rJ   r    r!   r"   s   @r   r   r      sF     
0 
0"""&".  ! !r   c                      a a ] tR t^t oRt ! R R]P                  4      tV 3R ltR t	R t
RR ltRR ltR	 tR
 tR tRtVtV ;t# )r   zA pairing heap.c                   :   a a ] tR t^t oRtRtV 3R ltRtVtV ;t	# )PairingHeap._NodezrA node in a pairing heap.

A tree in a pairing heap is stored using the left-child, right-sibling
representation.
c                ^   < \         SV `  W4       R V n        R V n        R V n        R V n        R # r   )superr   leftnextprevparent)r   r   r   	__class__s   &&&r   r   PairingHeap._Node.__init__   s,    GS(DIDIDIDKr   )rR   rS   rU   rT   )rR   rS   rT   rU   )
r   r   r   r   r   r   r   r    r!   __classcell__rV   r#   s   @@r   _NoderO      s     	 7			 		r   rZ   c                2   < \         SV `  4        RV n        R# )zInitialize a pairing heap.N)rQ   r   _rootr   rV   s   &r   r   PairingHeap.__init__   s    
r   c                    V P                   f   \        P                  ! R4      hV P                   P                  V P                   P                  3# Nzheap is empty.)r\   nxNetworkXErrorr   r   r   s   &r   r,   PairingHeap.min   s;    ::""#344



 0 011r   c                    V P                   f   \        P                  ! R4      hV P                   pV P                  V P                   4      V n         V P                  VP
                   VP
                  VP                  3# r`   )r\   ra   rb   _merge_childrenr'   r   r   )r   min_nodes   & r   r0   PairingHeap.pop   s`    ::""#344::))$**5
JJx||$hnn--r   c                \    V P                   P                  V4      pVe   VP                  # T# r   )r'   r5   r   )r   r   r4   nodes   &&& r   r5   PairingHeap.get   s(    zz~~c"!-tzz:7:r   c                :   V P                   P                  V4      pV P                  pVe   W$P                  8  dO   W$n        WEJdB   W$P                  P                  8  d(   V P                  V4       V P                  WT4      V n        R# V'       dM   W$P                  8  d=   W$n        V P                  V4      pVe"   V P                  V P                  V4      V n        R# V P                  W4      pW@P                   V&   Ve   V P                  WT4      MTV n        R# )NTF)	r'   r5   r\   r   rU   _cut_linkre   rZ   )r   r   r   r8   ri   rootchilds   &&&&   r   r9   PairingHeap.insert   s    zz~~c"zzzz!"
#0A0A(AIIdO!%D!7DJEJJ$6"
,,T2 $!%DJJ!>DJ  ::c)D"JJsO373CD/DJr   c                    VP                   VP                   8  d   Y!r!VP                  pW2n        Ve   W#n        RVn        W!n        Wn        V# )zOLink two nodes, making the one with the smaller value the parent of
the other.
N)r   rR   rS   rT   rU   )r   rn   otherrS   s   &&& r   rm   PairingHeap._link   sH     ;;#%yy
I
	r   c                D   VP                   pRVn         Ve   V P                  pRp VP                  pVf   WBn        M%VP                  pV! W%4      pWBn        TpVf   MTpK=  VP                  pVe   VP                  pV! WB4      pTpK  RVn        RVn        RVn        V# )ztMerge the subtrees of the root using the standard two-pass method.
The resulting subtree is detached from the root.
N)rR   rm   rS   rT   rU   )r   rn   ri   linkrT   rS   	next_next	prev_prevs   &&      r   re   PairingHeap._merge_children   s     yy	::D
 Dyy< $I II	D' 	$  99D" II	D' DIDIDKr   c                    VP                   pVP                  pVe   W2n        MW1P                  n        RVn         Ve   W#n         RVn        RVn        R# )zCut a node from its parent.N)rT   rS   rU   rR   )r   ri   rT   rS   s   &&  r   rl   PairingHeap._cut
  sI    yyyyI#KK	IDIr   )r\   r   rL   )r   r   r   r   r   r   r$   rZ   r   r,   r0   r5   r9   rm   re   rl   r    r!   rX   rY   s   @@r   r   r      sG      (
2
.;"H$L r   c                   V   a a ] tR tRt oRtV 3R ltR tR tR	R ltR
R lt	Rt
VtV ;t# )r   i  zA binary heap.c                P   < \         SV `  4        . V n        \        4       V n        R# )zInitialize a binary heap.N)rQ   r   _heapr   _countr]   s   &r   r   BinaryHeap.__init__  s    
gr   c                    V P                   pV'       g   \        P                  ! R 4      hV P                  p V^ ,          w  r4pWQ9   d   W1V,          8X  d    WS3# \	        V4       K1  zheap is emptyr'   ra   rb   r}   r   r   dictheapr   _r   s   &     r   r,   BinaryHeap.min"  s\    zz""?33zz  GMEc{uS	1| DMr   c                    V P                   pV'       g   \        P                  ! R 4      hV P                  p V^ ,          w  r4p\	        V4       WQ9   g   K   W1V,          8X  g   K/   Y YS3# r   r   r   s   &     r   r0   BinaryHeap.pop0  s_    zz""?33zz  GMEcDM{uS	1I|r   c                8    V P                   P                  W4      # r   )r'   r5   r3   s   &&&r   r5   BinaryHeap.get?  s    zz~~c++r   c                .   V P                   pW9   dS   WA,          pW%8  g   V'       d;   W%8  d5   W$V&   \        V P                  V\        V P                  4      V34       W%8  # R # W$V&   \        V P                  V\        V P                  4      V34       R# )FT)r'   r   r}   rS   r~   )r   r   r   r8   r   	old_values   &&&&  r   r9   BinaryHeap.insertB  s    zz;	I ^8I
 "S	eT$++->%DE((ITZZ%dkk):C!@Ar   )r~   r}   r   rL   )r   r   r   r   r   r   r,   r0   r5   r9   r    r!   rX   rY   s   @@r   r   r     s&     , r   )r   r   r   )r   heapqr   r   	itertoolsr   networkxra   __all__r   r   r    r   r   <module>r      sB    $  
2t! t!nR' Rj9 9r   