
    mBNj&                     @    d dl mZmZ ddlmZ ddlmZ  G d d      Zy)    )ListOptional   )Edge)Nodec                       e Zd ZdZdee   dee   fdZdee   fdZdee   fdZ	de
e   fdZde
e   fd	Zde
e   fd
Zde
e   fdZdefdZdefdZdefdZdefdZy)Patha  
    Path Class for representing a path in a graph.

    This class defines a path consisting of nodes and edges.
    It provides methods for managing and manipulating the path.

    Example:
        node1 = Node()
        node2 = Node()
        edge1 = Edge(node1, "R", node2)

        path = Path.new_empty_path()
        path.add_node(node1).add_edge(edge1).add_node(node2)
        print(path)
        # Output: <(node1)-(edge1)->(node2)>
    nodesedgesc                     t        |t              rt        |t              st        d      || _        || _        t
        | _        y )Nznodes and edges must be list)
isinstancelist	TypeError_nodes_edgesr   append_type)selfr
   r   s      ^/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/falkordb/path.py__init__zPath.__init__   s7    5$'Jud,C:;;    returnc                     | j                   S )zw
        Returns the list of nodes in the path.

        Returns:
            list: List of nodes in the path.
        )r   r   s    r   r
   z
Path.nodes!        {{r   c                     | j                   S )zw
        Returns the list of edges in the path.

        Returns:
            list: List of edges in the path.
        )r   r   s    r   r   z
Path.edges*   r   r   c                 Z    d|cxk  r| j                         k  rn y| j                  |   S y)z
        Returns the node at the specified index in the path.

        Args:
            index (int): Index of the node.

        Returns:
            Node: The node at the specified index.
        r   N
node_countr   r   indexs     r   get_nodezPath.get_node3   1     )))  ;;u%%r   c                 Z    d|cxk  r| j                         k  rn y| j                  |   S y)z
        Returns the edge at the specified index in the path.

        Args:
            index (int): Index of the edge.

        Returns:
            Edge: The edge at the specified index.
        r   N)
edge_countr   r   s     r   get_edgezPath.get_edgeB   r"   r   c                 J    | j                         dkD  r| j                  d   S dS )zu
        Returns the first node in the path.

        Returns:
            Node: The first node in the path.
        r   Nr   r   s    r   
first_nodezPath.first_nodeQ   s%     "&!2Q!6t{{1~@D@r   c                 J    | j                         dkD  r| j                  d   S dS )zs
        Returns the last node in the path.

        Returns:
            Node: The last node in the path.
        r   Nr   r   s    r   	last_nodezPath.last_nodeZ   s%     #'//"3a"7t{{2ATAr   c                 ,    t        | j                        S )zz
        Returns the number of edges in the path.

        Returns:
            int: Number of edges in the path.
        )lenr   r   s    r   r$   zPath.edge_countc        4;;r   c                 ,    t        | j                        S )zz
        Returns the number of nodes in the path.

        Returns:
            int: Number of nodes in the path.
        )r,   r   r   s    r   r   zPath.node_countl   r-   r   c                     t        |t              sy| j                         |j                         k(  xr! | j                         |j                         k(  S )z
        Compares two Path instances for equality based on their nodes and edges.

        Args:
            other (Path): Another Path instance for comparison.

        Returns:
            bool: True if the paths are equal, False otherwise.
        F)r   r	   r
   r   )r   others     r   __eq__zPath.__eq__u   s>     %&zz|u{{},N1NNr   c                    d}| j                         }t        d|      D ]  }| j                  |   }|j                  }|dt	        |      z   dz   z  }| j
                  |   }|j                  t	        t        |j                              nd}||j                  |k(  rd|z   dz   nd|z   d	z   z  } | j                  |   }|dt	        |j                        z   dz   z  }|d
z  }|S )z
        Returns a string representation of the path, including nodes and edges.

        Returns:
            str: String representation of the path.
        <r   () z-[z]->z<-[z]->)r$   ranger   idstrr   intsrc_node)	r   resr$   inodenode_idedgeedge_id_strr*   s	            r   __str__zPath.__str__   s     __&
q*%A;;q>DggG3W%++C;;q>D/3ww/B#c$''l+K==G+ {"U*[(4/C & KK
+	sS&&,,s

r   N)__name__
__module____qualname____doc__r   r   r   r   r
   r   r   r!   r%   r'   r*   r;   r$   r   boolr1   r:   rC    r   r   r	   r	      s    " d4j  d  tDz tDz $ $ AHTN AB8D> B C   C  Ot O  r   r	   N)typingr   r   rA   r   r?   r   r	   rI   r   r   <module>rK      s    !  U Ur   