
    mBNjl+                    X   d Z ddlmZ ddlmZ ddlmZ	 e	j                  rddlmZ nddlmZ g dZ e	j                   d      Z G d	 d
      Z G d de	j
                  ee	j(                  f         Z G d dee	j,                  e         Z G d de      Z G d de      Z G d d      Zy)z)Graph data types as returned by the DBMS.    )annotations)Mapping   )_typing)
deprecated)GraphNodePathRelationship_Tc                  \    e Zd ZdZd	dZed
d       Zedd       ZddZd Z	e
dd       Zy)r   a  
    A graph of nodes and relationships.

    Local, self-contained graph object that acts as a container for
    :class:`.Node` and :class:`.Relationship` instances.
    This is typically obtained via :meth:`.Result.graph` or
    :meth:`.AsyncResult.graph`.
    c                    i | _         i | _        i | _        t        | j                         | _        t        | j                        | _        y N)_nodes_relationships_relationship_typesEntitySetView_node_set_view_relationship_set_viewselfs    e/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/neo4j/graph/__init__.py__init__zGraph.__init__7   s=    ')79BD +DKK8&3D4G4G&H#    c                    | j                   S )z-Access a set view of the nodes in this graph.)r   r   s    r   nodeszGraph.nodes>        """r   c                    | j                   S )z5Access a set view of the relationships in this graph.)r   r   s    r   relationshipszGraph.relationshipsC   s     ***r   c           	         	 | j                   |   }|S # t        $ rM t        j                  t        t
           t	        t        |      t
        fi             x}| j                   |<   Y |S w xY w)zAObtain the relationship class for a given relationship type name.)r   KeyError_tcasttyper   str)r   nameclss      r   relationship_typezGraph.relationship_typeH   so    	**40C
 
	  	3577\"DT\OR$H4 C$**40 
		s    AA)(A)c                    | j                   j                         }t        |j                  di       j	                               }|f}t
        j                  ||fS Nr   )__dict__copytuplepopkeysr   _restore)r   staterelationship_typesrestore_argss       r   
__reduce__zGraph.__reduce__R   sM    ""$"599-BB#G#L#L#NO*,~~|U22r   c           	         t               j                  t               }| D ci c]  }|t        t        |      t        fi         c}|j
                  d<   |S c c}w r*   )r   __new__r$   r%   r   r+   )r2   graphr&   s      r   r0   zGraph._restoreX   s[    & +1
* $s4y</266*1
,- 	1
s   #AN)returnNone)r8   zEntitySetView[Node])r8   zEntitySetView[Relationship])r&   r%   r8   ztype[Relationship])r2   ztuple[str, ...]r8   r   )__name__
__module____qualname____doc__r   propertyr   r   r(   r4   staticmethodr0    r   r   r   r   -   sS    I # # + +3  r   r   c                      e Zd ZdZ	 	 	 	 	 	 	 	 	 	 ddZddZd ZddZddZddZ	ddZ
edd	       Ze ed
      dd              Zedd       ZdddZddZddZddZy)Entityz
    Graph entity base.

    Base class for :class:`.Node` and :class:`.Relationship` that
    provides :class:`.Graph` membership and property containment
    functionality.
    c                    || _         || _        || _        |xs i j                         D ci c]  \  }}|	|| c}}| _        y c c}}w r   )_graph_element_id_iditems_properties)r   r7   
element_idid_
propertieskvs          r   r   zEntity.__init__k   sV     %(.B557
7TQ1=AqD7
 
s
   
AAc                    	 t        |       t        |      u xr4 | j                  |j                  k(  xr | j                  |j                  k(  S # t        $ r	 t        cY S w xY wr   )r$   r7   rI   AttributeErrorNotImplementedr   others     r   __eq__zEntity.__eq__y   s_    	"T
d5k) 8JJ%++-8OOu'7'77
  	"!!	"s   AA A A c                ,    t        | j                        S r   )hashrE   r   s    r   __hash__zEntity.__hash__       D$$%%r   c                ,    t        | j                        S r   )lenrH   r   s    r   __len__zEntity.__len__   s    4##$$r   c                8    | j                   j                  |      S r   rH   getr   r&   s     r   __getitem__zEntity.__getitem__   s    ##D))r   c                    || j                   v S r   )rH   r^   s     r   __contains__zEntity.__contains__   s    t''''r   c                ,    t        | j                        S r   )iterrH   r   s    r   __iter__zEntity.__iter__   rW   r   c                    | j                   S )z1The :class:`.Graph` to which this entity belongs.)rD   r   s    r   r7   zEntity.graph        {{r   z,`id` is deprecated, use `element_id` insteadc                    | j                   S )a  
        The legacy identity of this entity in its container :class:`.Graph`.

        Depending on the version of the server this entity was retrieved from,
        this may be empty (None).

        .. warning::
            This value can change for the same entity across multiple
            transactions. Don't rely on it for cross-transactional
            computations.

        .. deprecated:: 5.0
            Use :attr:`.element_id` instead.
        )rF   r   s    r   idz	Entity.id   s    " xxr   c                    | j                   S )a'  
        The identity of this entity in its container :class:`.Graph`.

        .. warning::
            This value can change for the same entity across multiple
            transactions. Don't rely on it for cross-transactional
            computations.

        .. versionadded:: 5.0
        )rE   r   s    r   rI   zEntity.element_id   s     r   Nc                :    | j                   j                  ||      S )z8Get a property value by name, optionally with a default.r\   )r   r&   defaults      r   r]   z
Entity.get   s    ##D'22r   c                6    | j                   j                         S )z)Return an iterable of all property names.)rH   r/   r   s    r   r/   zEntity.keys   s    $$&&r   c                6    | j                   j                         S )z*Return an iterable of all property values.)rH   valuesr   s    r   rn   zEntity.values   s    &&((r   c                6    | j                   j                         S )z4Return an iterable of all property name-value pairs.)rH   rG   r   s    r   rG   zEntity.items   s    %%''r   )
r7   r   rI   r%   rJ   intrK   dict[str, _t.Any] | Noner8   r9   rR   _t.Anyr8   boolr8   rp   )r&   r%   r8   rs   )r&   objectr8   rt   )r8   z_t.Iterator[str]r8   r   r8   r%   r   )r&   r%   rk   rv   r8   rs   )r8   z_t.KeysView[str])r8   z_t.ValuesView[_t.Any])r8   z_t.ItemsView[str, _t.Any])r:   r;   r<   r=   r   rS   rV   rZ   r_   ra   rd   r>   r7   _deprecatedrh   rI   r]   r/   rn   rG   r@   r   r   rB   rB   b   s    

 
 	

 -
 

"&%*(&   ?@ A "    3')(r   rB   c                  8    e Zd ZdZ	 	 	 	 ddZddZd	dZd
dZy)r   zEView of a set of :class:`.Entity` instances within a :class:`.Graph`.c                    || _         y r   _entity_dict)r   entity_dicts     r   r   zEntitySetView.__init__   s     (r   c                     | j                   |   S r   r|   )r   e_ids     r   r_   zEntitySetView.__getitem__   s      &&r   c                ,    t        | j                        S r   )rY   r}   r   s    r   rZ   zEntitySetView.__len__   s    4$$%%r   c                H    t        | j                  j                               S r   )rc   r}   rn   r   s    r   rd   zEntitySetView.__iter__   s    D%%,,.//r   N)r~   zdict[str, _T]r8   r9   )r   r%   r8   r   ru   )r8   z_t.Iterator[_T])r:   r;   r<   r=   r   r_   rZ   rd   r@   r   r   r   r      s+    O("( 
('&0r   r   c                  N    e Zd ZdZ	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZddZed	d       Zy)
r	   zSelf-contained graph node.Nc                ^    t         j                  | ||||       t        |xs d      | _        y )Nr@   )rB   r   	frozenset_labels)r   r7   rI   rJ   n_labelsrK   s         r   r   zNode.__init__   s(     	eZjA R0r   c                V    d| j                   d| j                  d| j                  dS )Nz<Node element_id=z labels= properties=>)rE   r   rH   r   s    r   __repr__zNode.__repr__   s9     0 03 4ll%\$2B2B1EQH	
r   c                    | j                   S )z(The set of labels attached to this node.)r   r   s    r   labelszNode.labels   s     ||r   )NN)r7   r   rI   r%   rJ   rp   r   z_t.Iterable[str] | NonerK   rq   r8   r9   rx   )r8   zfrozenset[str])r:   r;   r<   r=   r   r   r>   r   r@   r   r   r	   r	      se    $ -1/3	1	1 	1 		1
 *	1 -	1 
	1
  r   r	   c                      e Zd ZdZ	 	 	 	 	 	 	 	 	 	 ddZddZedd       Zedd       Zedd       Z	edd       Z
d Zedd	       Zy
)r   z"Self-contained graph relationship.c                R    t         j                  | ||||       d | _        d | _        y r   )rB   r   _start_node	_end_node)r   r7   rI   rJ   rK   s        r   r   zRelationship.__init__   s'     	eZjA(,&*r   c           	     p    d| j                   d| j                  d| j                  d| j                  d	S )Nz<Relationship element_id=z nodes=z type=r   r   )rE   r   r$   rH   r   s    r   r   zRelationship.__repr__  sE    '(8(8'; <ZZN& 6**-Q0	
r   c                2    | j                   | j                  fS )z7Get the pair of nodes which this relationship connects.)r   r   r   s    r   r   zRelationship.nodes  s     //r   c                    | j                   S )z(Get the start node of this relationship.)r   r   s    r   
start_nodezRelationship.start_node  s     r   c                    | j                   S )z&Get the end node of this relationship.)r   r   s    r   end_nodezRelationship.end_node  s     ~~r   c                ,    t        |       j                  S )z
        Get the type name of this relationship.

        This is functionally equivalent to ``type(relationship).__name__``.
        )r$   r:   r   s    r   r$   zRelationship.type  s     Dz"""r   c                h    t         j                  | j                  | j                  f| j                  fS r   )r   r0   r7   r$   r+   r   s    r   r4   zRelationship.__reduce__#  s&    $$tzz499&=t}}LLr   c                F    | j                  |      }|j                  |      S r   )r(   r6   )r7   r&   type_s      r   r0   zRelationship._restore&  s!    ''-}}U##r   N)
r7   r   rI   r%   rJ   rp   rK   zdict[str, _t.Any]r8   r9   rx   )r8   ztuple[Node | None, Node | None])r8   zNode | None)r7   r   r&   r%   r8   r   )r:   r;   r<   r=   r   r   r>   r   r   r   r$   r4   r?   r0   r@   r   r   r   r      s    ,	+	+ 	+ 		+
 &	+ 
	+
 0 0       # #M $ $r   r   c                      e Zd ZdZddZddZddZd ZddZddZ	e
dd       Ze
dd	       Ze
dd
       Ze
dd       Ze
dd       Zy)r
   zSelf-contained graph path.c                   t        |t              sJ |g}t        |d      D ]  \  }}t        |t              sJ |j                  |d   k(  r4|j                  t        j                  t        |j                               ^|j                  |d   k(  r4|j                  t        j                  t        |j                               t        d| d       t        |      | _        || _        y )N   )startzRelationship z" does not connect to the last node)
isinstancer	   	enumerater   r   appendr"   r#   r   
ValueErrorr-   r   r   )r   r   r   r   irelationships         r   r   zPath.__init__/  s    *d+++(a@OA|lL999&&%)3RWWT<+@+@AB&&%)3RWWT<+B+BCD #A3&HI   A El+r   c                T    d| j                   d| j                  dt        |        dS )Nz<Path start=z end=z size=r   )r   r   rY   r   s    r   r   zPath.__repr__?  s4    4??-U4==2C DI;a!	
r   c                    	 | j                   |j                   k(  xr | j                  |j                  k(  S # t        $ r	 t        cY S w xY wr   )r   r   rO   rP   rQ   s     r   rS   zPath.__eq__E  sN    	"5#3#33 >&&%*=*==  	"!!	"s   36 AAc                t    t        | j                  d         }| j                  D ]  }|t        |      z  } |S )Nr   )rU   r   r   )r   valuer   s      r   rV   zPath.__hash__N  s8    T[[^$ //LT,''E 0r   c                ,    t        | j                        S r   )rY   r   r   s    r   rZ   zPath.__len__T  s    4&&''r   c                ,    t        | j                        S r   )rc   r   r   s    r   rd   zPath.__iter__W  s    D''((r   c                4    | j                   d   j                  S )z/The :class:`.Graph` to which this path belongs.r   )r   r7   r   s    r   r7   z
Path.graphZ  s     {{1~###r   c                    | j                   S )z4The sequence of :class:`.Node` objects in this path.r   r   s    r   r   z
Path.nodes_  rf   r   c                     | j                   d   S )z&The first :class:`.Node` in this path.r   r   r   s    r   r   zPath.start_noded  s     {{1~r   c                     | j                   d   S )z%The last :class:`.Node` in this path.r   r   r   s    r   r   zPath.end_nodei  s     {{2r   c                    | j                   S )z<The sequence of :class:`.Relationship` objects in this path.)r   r   s    r   r   zPath.relationshipsn  r   r   N)r   r	   r   r   r8   r9   rx   rr   ru   )r8   z_t.Iterator[Relationship]rw   )r8   ztuple[Node, ...])r8   r	   )r8   ztuple[Relationship, ...])r:   r;   r<   r=   r   r   rS   rV   rZ   rd   r>   r7   r   r   r   r   r@   r   r   r
   r
   ,  s    $, 
"() $ $       # #r   r
   N)r=   
__future__r   _collections.abcr   _Mapping r   r"   TYPE_CHECKINGtyping_extensionsr   ry   	_warnings__all__TypeVarr   r   r%   AnyrB   Genericr   r	   r   r
   r@   r   r   <module>r      s   & 0 ' /  ;5 RZZ2 2jd(RZZRVV$ d(N0Hbjjn 0&6 43$6 3$lE# E#r   