File: //opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyc
�
���ec @ s` d Z d d l m Z d d l m Z d d d g Z d � Z e d � Z d � Z d
� Z
d S( s Topological sorting algorithms.i ( t util( t CircularDependencyErrort sortt sort_as_subsetst find_cyclesc
c s� t j t � } x% | D] \ } } | | j | � q Wt | � } t | � } x� | r� g } x1 | D]) } | j | | � re | j | � qe qe W| s� t d t | | � t | � � � n | j
| � g | D] } | | k r� | ^ q� } | VqR Wd S( Ns Circular dependency detected.( R t defaultdictt sett addt listt
isdisjointt appendR R t
_gen_edgest difference_update(
t tuplest allitemst edgest parentt childt todot todo_sett outputt nodet t( ( sL /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyR s$
%c c s4 x- t | | � D] } x | D] } | Vq Wq Wd S( s, sort the given list of items by dependency.
'tuples' is a list of tuples representing a partial ordering.
deterministic_order is no longer used, the order is now always
deterministic given the order of "allitems". the flag is there
for backwards compatibility with Alembic.
N( R ( R
R t deterministic_ordert set_t s( ( sL /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyR + s
c C s t j t � } x% | D] \ } } | | j | � q Wt | � } t � } x� | D]� } | g } | j | � } x� | r| d }
x� | |
D]l } | | k r� | | j | � } | j | � | j | � n | | k r� | j | � | j | � Pq� q� W| j
� } qt WqS W| S( Ni����( R R R R t
differencet indexR t updateR
t removet pop( R
R R R R t
nodes_to_testR R t stackR t topt cyc( ( sL /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyR ; s*
c C s4 t g | D]# } | | D] } | | f ^ q q
� S( N( R ( R t leftt right( ( sL /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyR c s N( t __doc__t R t excR t __all__R t TrueR R R ( ( ( sL /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/util/topological.pyt <module> s (