관리-도구
편집 파일: topological.cpython-311.pyc
� �܋f� � �F � d Z ddlmZ ddlmZ g d�Zdd�Zdd�Zd� Zd � Z d S )zTopological sorting algorithms.� )�util)�CircularDependencyError)�sort�sort_as_subsets�find_cyclesFc # �� K � t j t � � }| D ] \ }}|| � |� � �!|rt j nt } ||� � }|r� |� � }|D ]2} |� || � � r|� | � � �3|s,t dt | |� � t |� � � � �|� |� � |V � |��d S d S )NzCircular dependency detected.) r �defaultdict�set�add� OrderedSet� isdisjointr r � _gen_edges�difference_update) �tuples�allitems�deterministic_order�edges�parent�child�Set�todo�output�nodes �R/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/util/topological.pyr r s � � � ���S�!�!�E�� !� !� ��� �e����� � � � �0� 9�$�/�/�c�C��3�x�=�=�D� � ������� !� !�D����u�T�{�+�+� !�� � �4� � � ��� �)�/��F�H�-�-��5�!�!�� � � ���v�&�&�&����� � � � � � � c # �D K � t | ||� � D ]}|D ]}|V � ��dS )z�sort the given list of items by dependency. 'tuples' is a list of tuples representing a partial ordering. 'deterministic_order' keeps items within a dependency tier in list order. N)r )r r r �set_�ss r r r , sM � � � � ���2E�F�F� � ��� � �A��G�G�G�G� �� r c �> � t j t � � }| D ] \ }}|| � |� � �!t |� � }t � � }|D ]�}|g}|� |� � } |r�|d } || D ]}}||v rG||� |� � d � }| � |� � |� |� � || v r,|� |� � | � |� � n�~|� � � }|����|S )N���)r r r r � difference�indexr �update�append�remove�pop)r r r r r � nodes_to_testr r �stackr �top�cycs r r r 8 sH � � ��S�!�!�E�� !� !� ��� �f� ���%� � � � ���J�J�M� �U�U�F� � #� #������'�'��.�.��� #���)�C��c� � #� #���5�=�=�����D� 1� 1� 3� 3�4�C��*�*�3�/�/�/��M�M�#�&�&�&��4�<�<��L�L��&�&�&��K�K��%�%�%��E� � �y�y�{�{�� � #�� �Mr c �: � � t � fd�� D � � � � S )Nc �. �� g | ]}�| D ]}||f���S � r- )�.0�left�rightr s �r � <listcomp>z_gen_edges.<locals>.<listcomp>a s. �� �I�I�I�$�U�4�[�I�I�E��� �I�I�I�Ir )r )r s `r r r ` s&