Ë
     |hÐ  ã                   ó,   — d dl Zd dlZd„ Zd„ Zd„ Zd„ Zy)é    Nc                 óÖ   — | j                  |«      D ]F  }| |   |   }	 d|d   d<   t        | ||«       |d   }|||dg}||d<   t        j                  ||«       ŒH y# t        $ r Y Œ4w xY w)a¼  Handles validation and invalidation of edges incident to a node.

    This function invalidates all existing edges incident on `node` and inserts
    new items in `heap_list` updated with the valid weights.

    rag : RAG
        The Region Adjacency Graph.
    node : int
        The id of the node whose incident edges are to be validated/invalidated
        .
    heap_list : list
        The list containing the existing heap of edges.
    Fú	heap itemé   ÚweightTN)Ú	neighborsÚ_invalidate_edgeÚKeyErrorÚheapqÚheappush)ÚragÚnodeÚ	heap_listÚnbrÚdataÚwtÚ	heap_items          úY/var/www/html/test/engine/venv/lib/python3.12/site-packages/skimage/graph/_graph_merge.pyÚ_revalidate_node_edgesr      s   € ð& }‰}˜TÓ"ò -ˆØ4‰y˜‰~ˆð	à#(ˆDÑ˜aÑ Ü˜S $¨Ô,ð (‰^ˆØ˜˜s DÐ)ˆ	Ø%ˆˆ[ÑÜ‰y )Õ,ñ-øô ò 	ñ ð	ús   žAÁ	A(Á'A(c                 ó
  — | j                  |«       | j                  |   j                  | j                  |   «       | j                  |«      D ]"  }| |   |   d   }| j	                  ||d|i«       Œ$ | j                  |«       y)z)Rename `node_id` in `graph` to `copy_id`.r   N)Ú_add_node_silentÚnodesÚupdater   Úadd_edgeÚremove_node)ÚgraphÚnode_idÚcopy_idr   r   s        r   Ú_rename_noder   )   s   € ð 
×Ñ˜7Ô#Ø	‡KKÑ×Ñ §¡¨GÑ 4Ô5à‰˜wÓ'ò 5ˆØ7‰^˜CÑ  Ñ*ˆØ‰s˜G h° ^Õ4ð5ð 
×ÑgÕó    c                 ó    — d| |   |   d   d<   y)z*Invalidates the edge (n1, n2) in the heap.Fr   r   N© )r   Ún1Ún2s      r   r   r   6   s   € à$)€Eˆ"IˆbM+Ñ˜qÒ!r   c                 ó:  — |r|j                  «       }g }|j                  d¬«      D ],  \  }}	}
|
d   }|||	dg}t        j                  ||«       ||
d<   Œ. t	        |«      dkD  rÙ|d   d   |k  rÎt        j
                  |«      \  }}}	}|r˜|j                  |«      D ]  }t        |||«       Œ |j                  |	«      D ]  }t        ||	|«       Œ |s"|j                  «       }t        ||	|«       ||}}n||	}} ||||«       |j                  |||«      }t        |||«       t	        |«      dkD  r|d   d   |k  rŒÎt        j                  | j                  «       dz   «      }t        |j!                  d¬«      «      D ]  \  }\  }}|d   D ]  }|||<   Œ	 Œ ||    S )a1  Perform hierarchical merging of a RAG.

    Greedily merges the most similar pair of nodes until no edges lower than
    `thresh` remain.

    Parameters
    ----------
    labels : ndarray
        The array of labels.
    rag : RAG
        The Region Adjacency Graph.
    thresh : float
        Regions connected by an edge with weight smaller than `thresh` are
        merged.
    rag_copy : bool
        If set, the RAG copied before modifying.
    in_place_merge : bool
        If set, the nodes are merged in place. Otherwise, a new node is
        created for each merge..
    merge_func : callable
        This function is called before merging two nodes. For the RAG `graph`
        while merging `src` and `dst`, it is called as follows
        ``merge_func(graph, src, dst)``.
    weight_func : callable
        The function to compute the new weights of the nodes adjacent to the
        merged node. This is directly supplied as the argument `weight_func`
        to `merge_nodes`.

    Returns
    -------
    out : ndarray
        The new labeled array.

    T)r   r   r   r   é   Úlabels)ÚcopyÚedgesr
   r   ÚlenÚheappopr   r   Únext_idr   Úmerge_nodesr   ÚnpÚarangeÚmaxÚ	enumerater   )r&   r   ÚthreshÚrag_copyÚin_place_mergeÚ
merge_funcÚweight_funcÚ	edge_heapr"   r#   r   r   r   Ú_Úvalidr   r+   ÚsrcÚdstÚnew_idÚ	label_mapÚixÚnÚdÚlabels                            r   Úmerge_hierarchicalrA   ;   sÏ  € ñJ Øh‰h‹jˆà€IØŸ	™	 t˜	Ó,ò &‰ˆˆBà(‰^ˆØ˜˜R Ð&ˆ	Ü‰y )Ô,ð &ˆˆ[Òð&ô ˆi‹.˜1Ò
 ¨1¡¨a¡°6Ò!9Ü Ÿ=™=¨Ó3Ñˆˆ2ˆr5ñ ð —}‘} RÓ(ò /Ü   b¨#Õ.ð/ð —}‘} RÓ(ò /Ü   b¨#Õ.ð/ñ "ØŸ+™+›-Ü˜S " gÔ.Ø˜wS‘à˜rSás˜C Ô%Ø—_‘_ S¨#¨{Ó;ˆFÜ" 3¨°	Ô:ô- ˆi‹.˜1Ò
 ¨1¡¨a¡°6Ó!9ô0 —	‘	˜&Ÿ*™*›,¨Ñ*Ó+€IÜ §	¡	¨t 	Ó 4Ó5ò "‰
ˆ‰FˆQØx‘[ò 	"ˆEØ!ˆIeÒñ	"ð"ð VÑÐr   )Únumpyr-   r
   r   r   r   rA   r!   r   r   ú<module>rC      s!   ðÛ Û ò!-òH
ò*ó
Or   