/percolation.pyc (e81344c0f958c1b9ef244749208d4c4f6ca91bd0) (6411 bytes) (mode 100644) (type blob)
�
���Vc @ s d d l j Z d d l Z d d l Z d d l Z d � Z d � Z d � Z
d � Z d � Z d � Z
d � Z d � Z d S(
i����Nc C s( d d t | j � � t | j � � S( Ng Y@g �?( t floatt num_vertices( t percolated_grapht intact_graph( ( s# /CORIA/Coria_backend/percolation.pyt percolation s c C sI d t | j � � d t | j � � GHd t t | | � � d GHd S( Ns filtered graph - vertices: s
/ edges: s
percolation: t %( t strR t num_edgesR ( t flct glc( ( s# /CORIA/Coria_backend/percolation.pyt
print_info s )c C s d GHd } i } x� t j j t | j j � � d t | j � � d t �D]� } d | j | j
j | � <| d 7} | | j � k rK | Gd GHt j
| j
d | j �} t j
| j
d t j | � �} t | | j � t | | j � | | | <qK qK W| S( Ns- Calculating percolation due to random failurei t sizet replacei s
nodes removedt vfilt( t npt randomt choicet listR t verticest maxt keyst Falset
exclusion_mapt gt vertext gtt GraphViewt label_largest_componentR
R ( t selft mode_namet nt countert resultst vt fR ( ( s# /CORIA/Coria_backend/percolation.pyt failure( s @
!!c C ss d GH| j j t j j d | j j � � d t �} t | j j � } t j j
| � t | | | | | � } | S( Ns* Calculating percolation due to random walki t use_index( R R R R t randintR R R t label_mapt at shufflet rw( R R R t startt alternate_listR ( ( s# /CORIA/Coria_backend/percolation.pyt random_walkA s 0c C s d GHi } i } t | j j � | j j � � } xW | D]O } | j j | j | | j t | j � � d d t d t
�j � | | <q: Wt | j j � | j
j � � } xP | D]H } | j j | j | t | j � � d d t d t
�j � | | <q� Wx
| | D]� } d G| GHd } d | j _ i | | <x� | | D]� }
t j | j | j |
� d } d | j | <| d 7} | | j � k rC| Gd GHt j | j d | j �} t j | j d t j | � �}
t |
| j � t |
| j � | | | | <qCqCWq
W| S(
Ns] Calculating percolation due to targeted attack , i.e. taking out top nodes from a target listi����t
withscorest score_cast_funcs Taking out top nodes for metrici i s
nodes removedR
( R t base_metricsR t advanced_metricst redist zranget
metric_prefixt normalization_suffixR R R t reverset scorest advanced_scorest score_prefixR R'