AlkantarClanX12

Your IP : 18.224.73.157


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/graphlib.cpython-310.opt-2.pyc

o

6��fe%�@s@ddgZdZdZGdd�d�ZGdd�de�ZGdd�d�ZdS)	�TopologicalSorter�
CycleError������c@seZdZdZdd�ZdS)�	_NodeInfo��node�
npredecessors�
successorscCs||_d|_g|_dS�N�r)�selfr�r
�//opt/alt/python310/lib64/python3.10/graphlib.py�__init__
s
z_NodeInfo.__init__N)�__name__�
__module__�__qualname__�	__slots__rr
r
r
rrsrc@seZdZ	dS)rN)rrrr
r
r
rrsc@s`eZdZ	ddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�ZdS)rNcCsLi|_d|_d|_d|_|dur"|��D]\}}|j|g|�R�qdSdSr
)�
_node2info�_ready_nodes�_npassedout�
_nfinished�items�add)rZgraphr�predecessorsr
r
rr*s�zTopologicalSorter.__init__cCs*|j�|�}durt|�|j|<}|S�N)r�getr)rr�resultr
r
r�
_get_nodeinfo4szTopologicalSorter._get_nodeinfocGsT	|jdur
td��|�|�}|jt|�7_|D]
}|�|�}|j�|�qdS)Nz/Nodes cannot be added after a call to prepare())r�
ValueErrorrr�lenr	�append)rrr�nodeinfoZpredZ	pred_infor
r
rr9s


�zTopologicalSorter.addcCsD	|jdur
td��dd�|j��D�|_|��}|r td|��dS)Nzcannot prepare() more than oncecSsg|]
}|jdkr|j�qS)r)rr)�.0�ir
r
r�
<listcomp>_sz-TopologicalSorter.prepare.<locals>.<listcomp>znodes are in a cycle)rrr�values�_find_cycler)r�cycler
r
r�prepareTs
�
�zTopologicalSorter.preparecCsX	|jdur
td��t|j�}|j}|D]}t||_q|j��|jt|�7_|S�N�prepare() must be called first)	rr�tupler�	_NODE_OUTr�clearrr )rr�n2irr
r
r�	get_readyjs
	

zTopologicalSorter.get_readycCs*	|jdur
td��|j|jkpt|j�Sr*)rrrr�bool�rr
r
r�	is_active�s
	zTopologicalSorter.is_activecCs|��Sr)r3r2r
r
r�__bool__�szTopologicalSorter.__bool__cGs�	|jdur
td��|j}|D]X}|�|�}dur"td|�d���|j}|tkrA|dkr5td|�d���|tkrAtd|�d���t|_|jD]}||}|jd8_|jdkr_|j�|�qG|j	d7_	qdS)Nr+znode z was not added using add()rz% was not passed out (still not ready)z was already marked done�)
rrrrrr-�
_NODE_DONEr	r!r)rZnodesr/rr"�statZ	successorZsuccessor_infor
r
r�done�s0

�

��zTopologicalSorter.donec	Cs�|j}g}g}t�}i}|D]Y}||vrq	||vr,||vr+|||d�|gSn|�|�|�t||j�j�t|�||<|�|�|rez|d�}Wntyb||�	�=|�	�Ynw|sInqqdS)NTr)
r�setrr!�iterr	�__next__r �
StopIteration�pop)rr/�stackZitstack�seenZnode2stackirr
r
rr'�s<�



���zTopologicalSorter._find_cycleccs@�	|��|��r|��}|EdH|j|�|��s
dSdSr)r)r3r0r8)rZ
node_groupr
r
r�static_order�s�

�zTopologicalSorter.static_orderr)
rrrrrrr)r0r3r4r8r'r@r
r
r
rr's

/%N)�__all__r-r6rrrrr
r
r
r�<module>s