o
    3ήc
                     @   s2   d dl Z d dlZdd Zdd ZG dd dZdS )    Nc                  C   s   t  } | jddd | jddd | jddd | jddd | jdd	d | jd
dd | jddd | jddd | g d | S )N   皙?percolation   皙?         333333?            ?   )r   r	   )r   r	   )r   r	   )r	   r
   )r
   r   )r   r   )r   r   nxGraphadd_nodeadd_edges_fromG r   g/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/centrality/tests/test_percolation_centrality.pyexample1a_G      r   c                  C   s   t  } | jddd | jddd | jddd | jddd | jd	dd | jd
dd | jddd | jddd | g d | S )Nr   r   r   r   r   r   r	   r   r
   r   r   r   r   r   r   r   r   r   r   example1b_G   r   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestPercolationCentralityc                 C   J   t  }t|}ddd}| D ]\}}|| tj|ddks"J qdS )"percolation centrality: example 1ag      ?gMbX?r	   r   MbP?absN)r   r   percolation_centralityitemspytestapproxselfr   pp_answernkr   r   r   test_percolation_example1a#      

z4TestPercolationCentrality.test_percolation_example1ac                 C   r   )r   gffffff?g?r    r!   r"   N)r   r   r$   r%   r&   r'   r(   r   r   r   test_percolation_example1b+   r/   z4TestPercolationCentrality.test_percolation_example1bc                 C   s   t  }dddddddddddd	d
ddd}dd | D }t j||d}t|D ]}|| tj|| ddks;J q*dd | D }t j||d}t|D ]}|| tj|| ddksaJ qPdS )zppercolation centrality: should converge to betweenness
        centrality when all nodes are percolated the sameg        gA`"?g+η?g9v?g)\(?gRQ?gNbX9?gI+?gv/?gM?g|?5^?gZd;O?)
AcciaiuoliAlbizzi	BarbadoriBischeri
CastellaniGinoriGuadagniLamberteschiMediciPazziPeruzziRidolfiSalviatiStrozzi
Tornabuonic                 S      i | ]\}}|d qS )g      ?r   .0r-   vr   r   r   
<dictcomp>J       zJTestPercolationCentrality.test_converge_to_betweenness.<locals>.<dictcomp>)statesr!   r"   c                 S   r@   )r   r   rA   r   r   r   rD   O   rE   N)r   florentine_families_graphr%   r$   sortedr&   r'   )r)   r   b_answerp_statesr+   r,   r   r   r   test_converge_to_betweenness3   s4     z6TestPercolationCentrality.test_converge_to_betweennessN)__name__
__module____qualname__r.   r0   rK   r   r   r   r   r   "   s    r   )r&   networkxr   r   r   r   r   r   r   r   <module>   s
    