
    sg                     p   d dl Z d dlZd dlmZ d dlmc mZ d dl	m
Z
 	 d dlZe j                  j                  edu d      ZdZ e j                   d       e j                   de j                  j#                  e      g      fZ e j&                  e	      d
        Ze j&                  d        Ze j                  j-                  dej.                  ej0                  ej2                  ej4                  ej6                  ej8                  ej:                  ej<                  g      d        Zd Z d Z!e j                  j-                  dejD                  ejF                  g      d        Z$e j                  j-                  dejJ                  ejL                  g      d        Z'd Z(d Z)d Z*y# e$ r dZY w xY w)    N)assert_equalzpydata/sparse not installed)reasonz>pydata/sparse (0.15.1) does not implement necessary operationsCOODOK)marks)paramsc                 6    t        t        | j                        S N)getattrsparseparam)requests    `/var/www/html/venv/lib/python3.12/site-packages/scipy/sparse/csgraph/tests/test_pydata_sparse.py
sparse_clsr      s    67==))    c                 f    g dg dg dg dg dg}t        j                  |      } | |      }||fS )N)r      r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )nparray)r   graphA_denseA_sparses       r   graphsr      s>     	E hhuoG'"HHr   funcc                 l    |\  }} | |      } | t        j                  |            }t        ||       y r
   sp
csc_matrixr   )r   r   r   r   actualdesireds         r   test_csgraph_equivr!   ,   s4     GX(^F2==)*G!r   c                     | \  }}t         j                  } ||      \  }} |t        j                  |            \  }}||k(  sJ t	        ||       y r
   )spgraphconnected_componentsr   r   r   )r   r   r   r   actual_compactual_labelsdesired_compdesired_labelss           r   test_connected_componentsr)   @   sU    GX''D!%hK$(w)?$@!L.,&&&/r   c                     | \  }}t        |      }t        j                  } ||      } |t        j                  |            }t        ||      sJ t        |j                         |j                                y r
   )typer#   	laplacianr   r   
isinstancer   todenser   r   r   r   r   r   r    s          r   test_laplacianr0   K   sd    GXhJD(^F2==)*Gfj)))!7??#45r   c                 p    | \  }} ||d      } |t        j                  |      d      }t        ||       y Nr   r   )r   r   r   r   r   r    s         r   test_order_searchr3   X   s9     GX(AF2==)1-G!r   c                     | \  }}t        |      } ||d      } |t        j                  |      d      }t        ||      sJ t	        |j                         |j                                y r2   )r+   r   r   r-   r   r.   )r   r   r   r   r   r   r    s          r   test_tree_searchr5   d   s`     GXhJ(AF2==)1-Gfj)))!7??#45r   c                     | \  }}t        |      }t        j                  } ||      } |t        j                  |            }t        ||      sJ t        |j                         |j                                y r
   )r+   r#   minimum_spanning_treer   r   r-   r   r.   r/   s          r   test_minimum_spanning_treer8   s   sd    GXhJ((D(^F2==)*Gfj)))!7??#45r   c                 p   | \  }}t        |      }t        j                  } ||dd      } |t        j                  |      dd      }|j
                  |j
                  k(  sJ t        |j                  |      sJ t        |j                  j                         |j                  j                                y )Nr      )
r+   r#   maximum_flowr   
csr_matrix
flow_valuer-   flowr   r.   r/   s          r   test_maximum_flowr?      s    GXhJD(Aq!F2==)1a0G 2 2222fkk:...$$&(<(<(>?r   c                     | \  }}t         j                  } ||ddddf         } |t        j                  |      ddddf         }t	        ||       y )Nr   r:   r      )r#   "min_weight_full_bipartite_matchingr   r   r   )r   r   r   r   r   r    s         r   'test_min_weight_full_bipartite_matchingrC      s`    GX55D(1Q3!8$%F2==)!A#qs(34G!r   )+pytestnumpyr   scipy.sparser   r   scipy.sparse.csgraphcsgraphr#   numpy.testingr   	Exceptionmarkskipif
pytestmarkmsgr   xfailsparse_paramsfixturer   r   parametrizeshortest_pathdijkstrafloyd_warshallbellman_fordjohnsonreverse_cuthill_mckeemaximum_bipartite_matchingstructural_rankr!   r)   r0   breadth_first_orderdepth_first_orderr3   breadth_first_treedepth_first_treer5   r8   r?   rC    r   r   <module>r`      s      & & & [[$'D   F
 G e$eFKK,=,=S,=,I+JKM }%* &* 
 
 
%%**	""0
6 
W(('*C*CD"" 
W'')A)AB	6	6
6@"G  Fs   F* *F54F5