Jz`f%cs^SSKJr SS/rSrSr"SS5r"SS\5r"S S5rg ) ) GenericAliasTopologicalSorter CycleErrorics\rSrSrSrSrSrg) _NodeInfoi node npredecessors successorscs,XlSUl/UlgNrr)selfr !/usr/lib64/python3.13/graphlib.py__init__Z_NodeInfo.__init__ s )r rrN)__name__ __module__ __qualname____firstlineno__Z __slots__r__static_attributes__rr rr s 5I rrcs\rSrSrSrSrg)ria#Subclass of ValueError raised by TopologicalSorter.prepare if cycles exist in the working graph. If multiple cycles exist, only one undefined choice among them will be reported and included in the exception. The detected cycle can be accessed via the second element in the *args* attribute of the exception instance and consists in a list of nodes, such that each node is, in the graph, an immediate predecessor of the next node in the list. In the reported list, the first and the last node will be the same, to make it clear that it is cyclic. rN)rrrr__doc__rrrr rrs   rcsh\rSrSrSrSSjrSrSrSrSr S r S r S r S r S r\"\5rSrg)ri)zFProvides functionality to topologically sort a graph of hashable nodesNcs0UlSUlSUlSUlUb-UR 5Hup#UR "U/UQ76 M ggr ) _node2info _ready_nodes _npassedout _nfinishedZitemsadd)r Zgraphr predecessors r rZTopologicalSorter.__init__,sT   &+kkm ."- - . rcsvURRU5=nc[U5=URU'nU$N)rgetr)r rresult r _get_nodeinfoZTopologicalSorter._get_nodeinfo6s8oo))$/ /F 8-6t_ ? ?!OO224 18LFAFF   " 3e< <  s B BcsURc [S5e[UR5nURnUHn[X#lM URR 5 U=R[U5- slU$)ayReturn a tuple of all the nodes that are ready. Initially it returns all nodes with no predecessors; once those are marked as processed by calling "done", further calls will return all new nodes that have all their predecessors already processed. Once no more progress can be made, empty tuples are returned. Raises ValueError if called without calling "prepare" previously. prepare() must be called first) rr#Ztupler _NODE_OUTrZclearrr$)r r n2irrr get_readyZTopologicalSorter.get_readyls~    $=> >t(()oo 0D&/CI # 0 ! CK' rcsURc [S5eURUR:=(d [ UR5$)aReturn ``True`` if more progress can be made and ``False`` otherwise. Progress can be made if cycles do not block the resolution and either there are still nodes ready that haven't yet been returned by "get_ready" or the number of nodes marked "done" is less than the number that have been returned by "get_ready". Raises ValueError if called without calling "prepare" previously. r))rr#rrZboolr  r is_activeZTopologicalSorter.is_activesA    $=> >!1!11LT$:K:K5LLrcs"UR5$r)r/r-r.r __bool__ZTopologicalSorter.__bool__s~~rcs$URc [S5eURnUHnURU5=nc[SU<S35eURnU[ :wa0US:a[SU<S35eU[ :Xa[SU<S35e[ UlURHInX&nU=RS-slURS:XdM.URRU5 MK U=RS- sl M g) aMarks a set of nodes returned by "get_ready" as processed. This method unblocks any successor of each node in *nodes* for being returned in the future by a call to "get_ready". Raises :exec:`ValueError` if any node in *nodes* has already been marked as processed by a previous call to this method, if a node was not added to the graph by using "add" or if called without calling "prepare" previously or if node has not yet been returned by "get_ready". Nr)znode z was not added using add()rz% was not passed out (still not ready)z was already marked donei) rr#rrrr* _NODE_DONEr r%r)r Znodesr+rr&ZstatZ successorZsuccessor_infos r doneZTopologicalSorter.dones    $=> >oo !D GGDM)2 50J!KLL))Dy 19$x'LMZ'$uTH4L%MNN &0H "&00 8 !$,,1,!//14%%,,Y7  8 OOq O9 !rcsURn/n/n[5n0nUHnXd;aM Xd;aXe;a X%USU/-s $O_URU5 UR[ XR 5R 5 [U5XV'URU5 U(a US"5nOMM g![a# XRR5 UR5 Of=fU(aMLNA)Nr) rZsetrr%Ziterr Z__next__r$Z StopIterationZpop)r r+ZstackZitstackZseenZ node2stackirs r r'ZTopologicalSorter._find_cyclesoou  D|<*$%6%89TFBB+HHTNNN4 (<(<#=#F#FG(+E K%LL&&&r{} /  8 )&' 4 & es) B;;*C('C(c#s# UR5 UR5(aAUR5nUShvN UR"U6 UR5(aM@ggN,7f)a)Returns an iterable of nodes in a topological order. The particular order that is returned may depend on the specific order in which the items were inserted in the graph. Using this method does not require to call "prepare" or "done". If any cycle is detected, :exc:`CycleError` will be raised. N)r(r/r,r2)r Z node_groupr r static_orderZTopologicalSorter.static_ordersP nn)J! ! ! IIz "nn !s;A,A*(A,(A,)r2rrrrrr)rrrrrrr"rr(r,r/r0r2r'r3Z classmethodrZ__class_getitem__rrrr rr)sGP. .6=,4 M -!^#J #$L1rN) ZtypesrZ__all__r*r1rr#rrrrr r4s>  -   "    Q2Q2r