o
    rPf                      @   s*   d dl mZ d dlmZ G dd dZdS )   )Edge)Nodec                   @   s   e Zd Zdd Zedd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )Pathc                 C   s2   t |tr
t |tstd|| _|| _t| _d S )Nznodes and edges must be list)
isinstancelist	TypeError_nodes_edgesr   append_type)selfnodesedges r   Z/var/www/html/humari/django-venv/lib/python3.10/site-packages/redis/commands/graph/path.py__init__   s
   
zPath.__init__c                 C   s
   | g g S Nr   )clsr   r   r   new_empty_path   s   
zPath.new_empty_pathc                 C      | j S r   r   r   r   r   r   r         z
Path.nodesc                 C   r   r   r	   r   r   r   r   r      r   z
Path.edgesc                 C   
   | j | S r   r   r   indexr   r   r   get_node      
zPath.get_nodec                 C   r   r   r   r   r   r   r   get_relationship   r   zPath.get_relationshipc                 C   
   | j d S )N    r   r   r   r   r   
first_node   r   zPath.first_nodec                 C   r   )Nr   r   r   r   r   	last_node!   r   zPath.last_nodec                 C   
   t | jS r   )lenr	   r   r   r   r   
edge_count$   r   zPath.edge_countc                 C   r$   r   )r%   r   r   r   r   r   nodes_count'   r   zPath.nodes_countc                 C   *   t || js
td| j| t| _| S )NzAdd Edge before adding Node)r   r
   AssertionErrorr   appendr   )r   noder   r   r   add_node*   
   zPath.add_nodec                 C   r(   )NzAdd Node before adding Edge)r   r
   r)   r	   r*   r   )r   edger   r   r   add_edge1   r-   zPath.add_edgec                 C   s.   t |tsdS |  | ko|  | kS )NF)r   r   r   r   )r   otherr   r   r   __eq__8   s   
 zPath.__eq__c                 C   s   d}|   }td|D ]4}| |j}|dt| d 7 }| |}||j|kr3dtt|j d n
dtt|j d 7 }q| |j}|dt| d 7 }|d	7 }|S )
N<r    ()z-[z]->z<-[z]->)r&   ranger   idstrr   src_nodeint)r   resr&   inode_idr.   r   r   r   __str__?   s   

zPath.__str__N)__name__
__module____qualname__r   classmethodr   r   r   r   r   r!   r#   r&   r'   r,   r/   r1   r>   r   r   r   r   r      s     
r   N)r.   r   r+   r   r   r   r   r   r   <module>   s    