+
    Ai!                     :    ^ RI t^ RIt^ RIHt ^RIHt R tR t	R# )    N)sparse)_ncut_cyc                    \         P                  ! V RR7      pVP                  ^ R7      p\        P                  ! V^ 3VP
                  R7      P                  4       pW13# )a  Returns the diagonal and weight matrices of a graph.

Parameters
----------
graph : RAG
    A Region Adjacency Graph.

Returns
-------
D : csc_array
    The diagonal matrix of the graph. ``D[i, i]`` is the sum of weights of
    all edges incident on `i`. All other entries are `0`.
W : csc_array
    The weight matrix of the graph. ``W[i, j]`` is the weight of the edge
    joining `i` to `j`.
csc)format)axis)shape)nxto_scipy_sparse_arraysumr   	dia_arrayr	   tocsc)graphWentriesDs   &   Q/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/graph/_ncut.pyDW_matricesr      sO    $ 	  u5AeeemG'1QWW5;;=A4K    c                p   \         P                  ! V 4      p \        P                  ! WP                  VP
                  VP                  VP                  ^ ,          R7      pVP                  V ,          P                  4       pVP                  V ( ,          P                  4       pW4,          W5,          ,           # )a0  Returns the N-cut cost of a bi-partition of a graph.

Parameters
----------
cut : ndarray
    The mask for the nodes in the graph. Nodes corresponding to a `True`
    value are in one set.
D : csc_array
    The diagonal matrix of the graph.
W : csc_array
    The weight matrix of the graph.

Returns
-------
cost : float
    The cost of performing the N-cut.

References
----------
.. [1] Normalized Cuts and Image Segmentation, Jianbo Shi and
       Jitendra Malik, IEEE Transactions on Pattern Analysis and Machine
       Intelligence, Page 889, Equation 2.
)num_cols)	nparrayr   cut_costdataindicesindptrr	   r   )cutr   r   r   assoc_aassoc_bs   &&&   r   	ncut_costr!       s{    0 ((3-C  ffaiiAGGTUJWH ffSkooGffcTl G8#566r   )
networkxr
   numpyr   scipyr    r   r   r!    r   r   <module>r'      s       2 7r   