ó
Ü™xTc           @   s^   d  d l  m Z d „  Z d „  Z d „  Z e d k rZ d  d l Z e d e j d ƒ n  d S(	   iÿÿÿÿ(   t   divisionc          C   sœ  d d l  m }  d d l  m } d d d g f d g  f d g  f d d g f g } |  d | ƒ } | d d d d g k s€ t ‚ | t | ƒ ƒ g  k sž t ‚ | t | ƒ d	 t ƒd d d d g k sÎ t ‚ d d d g f d g  f d g  f d d g f g } |  d | ƒ } | d d d d g k s.t ‚ | t | ƒ ƒ g  k sLt ‚ d
 d g f d d g f d d d g f d d g f g } |  d | ƒ } | d d d d
 g k s²t ‚ | t | ƒ ƒ d g k sÓt ‚ d d d d g f d g  f d g  f d d g f g } |  d | ƒ } | d d d d d g k s9t ‚ | t | ƒ ƒ g  k sWt ‚ t | d i d d g d 6d d g d 6d	 t ƒ ƒ d k s˜t ‚ d  S(   Niÿÿÿÿ(   t   stable(   t   strongly_connected_componentst   at   bt   dt   ct   connectionst   omit_single_node_componentsi    i   i   i   t   et   successors_by_nodet
   successor1t
   successor2t   node1t
   successor3t   node2i   (   R   (   R   (   R   (   R   (   i   i   (   t   libtbx.topological_sortR   R   t   AssertionErrort   dictt   Falset   len(   R   t   sccR   t	   node_list(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_topological_sort.pyt   exercise_specific   sJ    				!		!	c      
   C   sh  g  } x£ t  | ƒ D]• } |  j d ƒ d k r4 q n  t t | d ƒ |  j | ƒ ƒ } t | ƒ } x0 t  | ƒ D]" } |  j t | ƒ ƒ } | | =qo W| j | | f ƒ q Wd d l m } | d | ƒ d d l m	 }	 d d l m
 }
 t | ƒ } |	 d	 | ƒ } x] | D]U } xL | D]D } x; | D]3 } |
 d	 | d
 | d | ƒ } | d  k	 s%t ‚ q%WqWqWd  S(   Ni
   i   g333333ã?iÿÿÿÿ(   R   R   (   R   (   t	   find_pathR
   t	   from_nodet   to_node(   t   xranget	   randranget   maxt   intt   rangeR   t   appendR   R   R   R   R   t   NoneR   (   t   rngt   n_nodesR   t   i_nodet   n_delt   depst   i_delt   iR   R   R   t   sbnt
   componentst	   componentR   R   t   path(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_topological_sort.pyt   exercise_random.   s*    "c         C   sk   t  |  ƒ d k s t ‚ t ƒ  d d  l } | j d ƒ x' t d ƒ D] } t d | d d ƒ qE Wd GHd  S(   Ni    iÿÿÿÿi
   R"   R#   t   OK(   R   R   R   t   randomt   seedR   R-   (   t   argsR/   t   i_trial(    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_topological_sort.pyt   runG   s    t   __main__NR1   i   (   t
   __future__R    R   R-   R3   t   __name__t   syst   argv(    (    (    sI   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_topological_sort.pyt   <module>   s   	,			