§
    �Štjþ  ã                   ó,   — d dl mZ  G d„ d¦  «        ZdS )é    )Údequec                   óØ   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Ze	d„ ¦   «         Z
e	d„ ¦   «         Zd	„ Zd
„ Zdedee         fd„Zdedee         fd„Zdedefd„Zdedee         fd„Zdefd„ZdS )ÚDiGraphz´Really simple unweighted directed graph data structure to track dependencies.

    The API is pretty much the same as networkx so if you add something just
    copy their API.
    c                 óL   — i | _         i | _        i | _        i | _        d| _        d S )Nr   )Ú_nodeÚ_succÚ_predÚ_node_orderÚ_insertion_idx©Úselfs    úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/package/_digraph.pyÚ__init__zDiGraph.__init__   s1   € àˆŒ
ð ˆŒ
àˆŒ
ð ˆÔØˆÔÐÐó    c                 óÖ   — || j         vr?|| j         |<   i | j        |<   i | j        |<   | j        | j        |<   | xj        dz  c_        dS | j         |                              |¦  «         dS )zºAdd a node to the graph.

        Args:
            n: the node. Can we any object that is a valid dict key.
            **kwargs: any attributes you want to attach to the node.
        é   N)r   r   r	   r   r
   Úupdate)r   ÚnÚkwargss      r   Úadd_nodezDiGraph.add_node   s|   € ð �D”JÐÐØ"ˆDŒJ�q‰MØˆDŒJ�q‰MØˆDŒJ�q‰MØ"&Ô"5ˆDÔ˜QÑØÐÔ 1Ñ$ÐÔÐÐàŒJ�qŒM× Ò  Ñ(Ô(Ð(Ð(Ð(r   c                 óš   — |                       |¦  «         |                       |¦  «         d| j        |         |<   d| j        |         |<   dS )z‚Add an edge to graph between nodes ``u`` and ``v``

        ``u`` and ``v`` will be created if they do not already exist.
        TN)r   r   r	   )r   ÚuÚvs      r   Úadd_edgezDiGraph.add_edge*   sP   € ð 	�Š�aÑÔÐØ�Š�aÑÔÐð  ˆŒ
�1Œ�aÑØˆŒ
�1Œ�aÑÐÐr   c                 ó„   — 	 t          | j        |         ¦  «        S # t          $ r}t          d|› d�¦  «        |‚d}~ww xY w)z.Returns an iterator over successor nodes of n.ú	The node ú is not in the digraph.N)Úiterr   ÚKeyErrorÚ
ValueError©r   r   Úes      r   Ú
successorszDiGraph.successors7   ó[   € ð	LÝ˜œ
 1œÑ&Ô&Ð&øÝð 	Lð 	Lð 	LÝÐC¨ÐCÐCÐCÑDÔDÈ!ÐKøøøøð	Løøøó   ‚ œ
?¦:º?c                 ó„   — 	 t          | j        |         ¦  «        S # t          $ r}t          d|› d�¦  «        |‚d}~ww xY w)z1Returns an iterator over predecessors nodes of n.r   r   N)r   r	   r   r    r!   s      r   ÚpredecessorszDiGraph.predecessors>   r$   r%   c              #   ó^   K  — | j                              ¦   «         D ]\  }}|D ]}||fV — Œ	ŒdS )z6Returns an iterator over all edges (u, v) in the graphN)r   Úitems)r   r   r#   Úsuccs       r   ÚedgeszDiGraph.edgesE   sV   è è € ð "œZ×-Ò-Ñ/Ô/ð 	ð 	‰MˆAˆzØ"ð ð �Ø˜�g����ðð	ð 	r   c                 ó   — | j         S )z6Returns a dictionary of all nodes to their attributes.)r   r   s    r   ÚnodeszDiGraph.nodesL   s   € ð ŒzÐr   c                 ó*   — t          | j        ¦  «        S )zIterate over the nodes.)r   r   r   s    r   Ú__iter__zDiGraph.__iter__Q   s   € å�D”JÑÔÐr   c                 ó8   — 	 || j         v S # t          $ r Y dS w xY w)z>Returns True if ``n`` is a node in the graph, False otherwise.F)r   Ú	TypeError)r   r   s     r   Ú__contains__zDiGraph.__contains__U   s5   € ð	Ø˜œ
�?Ð"øÝð 	ð 	ð 	Ø�5�5ð	øøøs   ‚ ‹
˜ÚsrcÚreturnc                 óB  — t          |¦  «        }t          |¦  «        }t          |¦  «        dk    rm|                     ¦   «         }|                      |¦  «        D ]0}||vr*|                     |¦  «         |                     |¦  «         Œ1t          |¦  «        dk    °m|S )z2Returns a set of nodes that are reachable from srcr   )Úsetr   ÚlenÚpopleftr#   ÚaddÚappend©r   r3   ÚresultÚworking_setÚcurr   s         r   Úforward_transitive_closurez"DiGraph.forward_transitive_closure\   s¢   € õ �S‘”ˆÝ˜C‘j”jˆÝ�+ÑÔ Ò"Ð"Ø×%Ò%Ñ'Ô'ˆCØ—_’_ SÑ)Ô)ð *ð *�Ø˜F�?�?Ø—J’J˜q‘M”M�MØ×&Ò& qÑ)Ô)Ð)øõ �+ÑÔ Ò"Ð"ð ˆr   c                 óB  — t          |¦  «        }t          |¦  «        }t          |¦  «        dk    rm|                     ¦   «         }|                      |¦  «        D ]0}||vr*|                     |¦  «         |                     |¦  «         Œ1t          |¦  «        dk    °m|S )zGReturns a set of nodes that are reachable from src in reverse directionr   )r6   r   r7   r8   r'   r9   r:   r;   s         r   Úbackward_transitive_closurez#DiGraph.backward_transitive_closurei   s¤   € õ �S‘”ˆÝ˜C‘j”jˆÝ�+ÑÔ Ò"Ð"Ø×%Ò%Ñ'Ô'ˆCØ×&Ò& sÑ+Ô+ð *ð *�Ø˜F�?�?Ø—J’J˜q‘M”M�MØ×&Ò& qÑ)Ô)Ð)øõ �+ÑÔ Ò"Ð"ð ˆr   Údstc                 óœ  — t          ¦   «         }|                      |¦  «        }||vr|S t          |¦  «        }t          |¦  «        dk    rn|                     ¦   «         }|                      |¦  «        D ]1}||v r+|                     ||¦  «         |                     |¦  «         Œ2t          |¦  «        dk    °n|                     ¦   «         S )zAReturns a subgraph rooted at src that shows all the paths to dst.r   )	r   r?   r   r7   r8   r'   r   r:   Úto_dot)r   r3   rB   Úresult_graphÚforward_reachable_from_srcr=   r>   r   s           r   Ú	all_pathszDiGraph.all_pathsv   sá   € õ ‘y”yˆà%)×%DÒ%DÀSÑ%IÔ%IÐ"àÐ0Ð0Ð0ØÐõ
 ˜C‘j”jˆÝ�+ÑÔ Ò"Ð"Ø×%Ò%Ñ'Ô'ˆCØ×&Ò& sÑ+Ô+ð *ð *�ØÐ2Ð2Ð2Ø ×)Ò)¨!¨SÑ1Ô1Ð1à×&Ò& qÑ)Ô)Ð)øõ �+ÑÔ Ò"Ð"ð ×"Ò"Ñ$Ô$Ð$r   c                 ó  — g }|rk|                      |¦  «         | j        |                              ¦   «         }d\  }}|D ]-}| j                             |d¦  «        }|€ n|�||k     r|}|}Œ.|°kt          t          |¦  «        ¦  «        S )z_Returns a list of nodes that show the first path that resulted in dst being added to the graph.)Ú NN)r:   r	   Úkeysr
   ÚgetÚlistÚreversed)r   rB   ÚpathÚ
candidatesÚmin_idxÚ	candidateÚidxs          r   Ú
first_pathzDiGraph.first_pathŽ   sª   € àˆàð 
	$Ø�KŠK˜ÑÔÐØœ Cœ×-Ò-Ñ/Ô/ˆJØ#‰LˆC�Ø'ð $ð $�	ØÔ&×*Ò*¨9°dÑ;Ô;�Ø�;Ø�EØ�? c¨G¢m mØ!�GØ#�Cøð ð 
	$õ •H˜T‘N”NÑ#Ô#Ð#r   c                 óV   — d                      d„ | j        D ¦   «         ¦  «        }d|› d�S )zvReturns the dot representation of the graph.

        Returns:
            A dot representation of the graph.
        ú
c              3   ó.   K  — | ]\  }}d |› d|› d�V — ŒdS )ú"z" -> "z";N© )Ú.0ÚfÚts      r   ú	<genexpr>z!DiGraph.to_dot.<locals>.<genexpr>¦   s:   è è € ÐDÐD±°°AÐ,˜aÐ,Ð, qÐ,Ð,Ð,ÐDÐDÐDÐDÐDÐDr   z,digraph G {
rankdir = LR;
node [shape=box];
z
}
)Újoinr+   )r   r+   s     r   rD   zDiGraph.to_dot    sD   € ð —	’	ÐDÐD¸¼ÐDÑDÔDÑDÔDˆðð ð	ð ð ð 	r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r#   r'   Úpropertyr+   r-   r/   r2   Ústrr6   r?   rA   rG   rL   rS   rD   rX   r   r   r   r      sr  € € € € € ðð ð ð  ð  ð)ð )ð )ð  ð  ð  ðLð Lð LðLð Lð Lð ðð ñ „Xðð ðð ñ „Xðð ð  ð  ðð ð ð¨cð °c¸#´hð ð ð ð ð¨sð °s¸3´xð ð ð ð ð%˜Sð % sð %ð %ð %ð %ð0$˜cð $ d¨3¤ið $ð $ð $ð $ð$˜ð ð ð ð ð ð r   r   N)Úcollectionsr   r   rX   r   r   ú<module>re      sS   ðà Ð Ð Ð Ð Ð ðhð hð hð hð hñ hô hð hð hð hr   