§
    OŠtjR   ã                   óÒ   — d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ dgZeddd	œfed
diffZeeee	fZdd„Zefd„Zdd„Zeeddfd„Zd„ ddfd„ZdZdddœZed„ ddefd„ZdS )é    )ÚBasic)ÚExpr)ÚSymbol)ÚIntegerÚRationalÚFloat)ÚsreprÚdotprintÚblueÚellipse)ÚcolorÚshaper   ÚblackFc                 ó:  — d}t          | t          ¦  «        st          | ¦  «        }nm| j        st	          | ¦  «        }nV| j        }t          t          t          |¦  «        ¦  «        }t          | ¦  «        j	        ›dd 
                    |¦  «        ›d�}|r||f}|S )aN  A string that follows ```obj = type(obj)(*obj.args)``` exactly.

    Parameters
    ==========

    with_args : boolean, optional
        If ``True``, there will be a second argument for the return
        value, which is a tuple containing ``purestr`` applied to each
        of the subnodes.

        If ``False``, there will not be a second argument for the
        return.

        Default is ``False``

    Examples
    ========

    >>> from sympy import Float, Symbol, MatrixSymbol
    >>> from sympy import Integer # noqa: F401
    >>> from sympy.core.symbol import Str # noqa: F401
    >>> from sympy.printing.dot import purestr

    Applying ``purestr`` for basic symbolic object:
    >>> code = purestr(Symbol('x'))
    >>> code
    "Symbol('x')"
    >>> eval(code) == Symbol('x')
    True

    For basic numeric object:
    >>> purestr(Float(2))
    "Float('2.0', precision=53)"

    For matrix symbol:
    >>> code = purestr(MatrixSymbol('x', 2, 2))
    >>> code
    "MatrixSymbol(Str('x'), Integer(2), Integer(2))"
    >>> eval(code) == MatrixSymbol('x', 2, 2)
    True

    With ``with_args=True``:
    >>> purestr(Float(2), with_args=True)
    ("Float('2.0', precision=53)", ())
    >>> purestr(MatrixSymbol('x', 2, 2), with_args=True)
    ("MatrixSymbol(Str('x'), Integer(2), Integer(2))",
     ("Str('x')", 'Integer(2)', 'Integer(2)'))
    © ú(ú, ú))Ú
isinstancer   ÚstrÚargsr	   ÚtupleÚmapÚpurestrÚtypeÚ__name__Újoin)ÚxÚ	with_argsÚsargsÚrvr   s        úP/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/printing/dot.pyr   r      sŸ   € ðb €EÝ�a�ÑÔð ;Ý�‰VŒVˆˆØŒVð ;Ý�1‰XŒXˆˆàŒvˆÝ•c�' 4Ñ(Ô(Ñ)Ô)ˆÝ˜A‘w”wÔ'Ð'Ð'¨¯ª°5Ñ)9Ô)9Ð)9Ð)9Ð:ˆØð Ø�ˆYˆØ€Ió    c                 ód   — i }|D ]*\  }}t          | |¦  «        r|                     |¦  «         Œ+|S )aÚ   Merge style dictionaries in order

    Examples
    ========

    >>> from sympy import Symbol, Basic, Expr, S
    >>> from sympy.printing.dot import styleof
    >>> styles = [(Basic, {'color': 'blue', 'shape': 'ellipse'}),
    ...           (Expr,  {'color': 'black'})]

    >>> styleof(Basic(S(1)), styles)
    {'color': 'blue', 'shape': 'ellipse'}

    >>> x = Symbol('x')
    >>> styleof(x + 1, styles)  # this is an Expr
    {'color': 'black', 'shape': 'ellipse'}
    )r   Úupdate)ÚexprÚstylesÚstyleÚtypÚstys        r"   Ústyleofr+   N   sF   € ð$ €EØð ð ‰ˆˆSÝ�d˜CÑ Ô ð 	Ø�LŠL˜ÑÔÐøØ€Lr#   r   c                 ó~   — |                      d„ t          |                      ¦   «         ¦  «        D ¦   «         ¦  «        S )zÙ Print a dictionary of attributes

    Examples
    ========

    >>> from sympy.printing.dot import attrprint
    >>> print(attrprint({'color': 'blue', 'shape': 'ellipse'}))
    "color"="blue", "shape"="ellipse"
    c              3   ó    K  — | ]	}d |z  V — Œ
dS )z	"%s"="%s"Nr   )Ú.0Úitems     r"   ú	<genexpr>zattrprint.<locals>.<genexpr>q   s'   è è € ÐIÐI¨t˜+ dÑ*ÐIÐIÐIÐIÐIÐIr#   )r   ÚsortedÚitems)ÚdÚ	delimiters     r"   Ú	attrprintr5   g   s5   € ð �>Š>ÐIÐIµv¸a¿gºg¹i¼iÑ7HÔ7HÐIÑIÔIÑIÔIÐIr#   r   Tc                 ó&  — t          | |¦  «        }t          | t          ¦  «        r!| j        st	          | j        j        ¦  «        }n || ¦  «        }||d<   t          | ¦  «        }|r|dt	          |¦  «        z  z  }d|›dt          |¦  «        ›d�S )zé String defining a node

    Examples
    ========

    >>> from sympy.printing.dot import dotnode
    >>> from sympy.abc import x
    >>> print(dotnode(x))
    "Symbol('x')_()" ["color"="black", "label"="x", "shape"="ellipse"];
    Úlabelú_%sú"z" [z];)	r+   r   r   Úis_Atomr   Ú	__class__r   r   r5   )r&   r'   Ú	labelfuncÚposÚrepeatr(   r7   Úexpr_strs           r"   Údotnoder@   t   sž   € õ �D˜&Ñ!Ô!€Eå�$�ÑÔð   t¤|ð  Ý�D”NÔ+Ñ,Ô,ˆˆà�	˜$‘”ˆØ€Eˆ'�NÝ�t‰}Œ}€HØð %Ø�E�C ™HœHÑ$Ñ$ˆøØ#˜8˜8¥Y¨uÑ%5Ô%5Ð%5Ð%5Ð6Ð6r#   c                 ó.   — t          | t          ¦  «         S ©N©r   r   ©r   s    r"   ú<lambda>rE   Œ   s   € ¥j°µEÑ&:Ô&:Ð":€ r#   c                 óÈ   ‡‡—  || ¦  «        rg S t          | d¬¦  «        \  Š}|r0‰dt          ‰¦  «        z  z  Šˆfd„t          |¦  «        D ¦   «         }ˆfd„|D ¦   «         S )a�   List of strings for all expr->expr.arg pairs

    See the docstring of dotprint for explanations of the options.

    Examples
    ========

    >>> from sympy.printing.dot import dotedges
    >>> from sympy.abc import x
    >>> for e in dotedges(x+2):
    ...     print(e)
    "Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";
    "Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";
    T)r   r8   c                 óF   •— g | ]\  }}|›d t          ‰|fz   ¦  «        ›�‘ŒS )Ú_)r   )r.   ÚiÚar=   s      €r"   ú
<listcomp>zdotedges.<locals>.<listcomp>¡   sD   ø€ ð 1ð 1ð 1Ù�A�qð $% 1 1¥c¨#°°©*¡o¤o oÐ6ð 1ð 1ð 1r#   c                 ó"   •— g | ]}d ‰›d|›d�‘ŒS )r9   z" -> "z";r   )r.   rJ   r?   s     €r"   rK   zdotedges.<locals>.<listcomp>£   s(   ø€ ÐBÐBÐB°A°A 8 8 8¨Q¨Q¨QÐ/ÐBÐBÐBr#   )r   r   Ú	enumerate)r&   Úatomr=   r>   Úarg_strsr?   s     `  @r"   ÚdotedgesrP   Œ   sš   øø€ ð €tˆD�z„zð CØˆ	å$ T°TÐ:Ñ:Ô:Ñˆ�(Øð 	1Ø˜¥ C¡¤Ñ(Ñ(ˆHð1ð 1ð 1ð 1Ý% hÑ/Ô/ð1ñ 1ô 1ˆHàBÐBÐBÐB¸ÐBÑBÔBÐBr#   z|digraph{

# Graph style
%(graphstyle)s

#########
# Nodes #
#########

%(nodes)s

#########
# Edges #
#########

%(edges)s
}ÚTDÚout)ÚrankdirÚorderingc                 ó.   — t          | t          ¦  «         S rB   rC   rD   s    r"   rE   rE   »   s   € ­j¸½EÑ.BÔ.BÐ*B€ r#   Nc           	      ó.  ‡‡‡‡‡‡‡	‡
— t                                ¦   «         }|                     |¦  «         g Š	g Šdˆˆˆˆˆ	ˆˆˆ
fd„	Š
 ‰
| d¦  «         t          t	          |d¬¦  «        d                     ‰	¦  «        d                     ‰¦  «        dœz  S )a°	  DOT description of a SymPy expression tree

    Parameters
    ==========

    styles : list of lists composed of (Class, mapping), optional
        Styles for different classes.

        The default is

        .. code-block:: python

            (
                (Basic, {'color': 'blue', 'shape': 'ellipse'}),
                (Expr,  {'color': 'black'})
            )

    atom : function, optional
        Function used to determine if an arg is an atom.

        A good choice is ``lambda x: not x.args``.

        The default is ``lambda x: not isinstance(x, Basic)``.

    maxdepth : integer, optional
        The maximum depth.

        The default is ``None``, meaning no limit.

    repeat : boolean, optional
        Whether to use different nodes for common subexpressions.

        The default is ``True``.

        For example, for ``x + x*y`` with ``repeat=True``, it will have
        two nodes for ``x``; with ``repeat=False``, it will have one
        node.

        .. warning::
            Even if a node appears twice in the same object like ``x`` in
            ``Pow(x, x)``, it will still only appear once.
            Hence, with ``repeat=False``, the number of arrows out of an
            object might not equal the number of args it has.

    labelfunc : function, optional
        A function to create a label for a given leaf node.

        The default is ``str``.

        Another good option is ``srepr``.

        For example with ``str``, the leaf nodes of ``x + 1`` are labeled,
        ``x`` and ``1``.  With ``srepr``, they are labeled ``Symbol('x')``
        and ``Integer(1)``.

    **kwargs : optional
        Additional keyword arguments are included as styles for the graph.

    Examples
    ========

    >>> from sympy import dotprint
    >>> from sympy.abc import x
    >>> print(dotprint(x+2)) # doctest: +NORMALIZE_WHITESPACE
    digraph{
    <BLANKLINE>
    # Graph style
    "ordering"="out"
    "rankdir"="TD"
    <BLANKLINE>
    #########
    # Nodes #
    #########
    <BLANKLINE>
    "Add(Integer(2), Symbol('x'))_()" ["color"="black", "label"="Add", "shape"="ellipse"];
    "Integer(2)_(0,)" ["color"="black", "label"="2", "shape"="ellipse"];
    "Symbol('x')_(1,)" ["color"="black", "label"="x", "shape"="ellipse"];
    <BLANKLINE>
    #########
    # Edges #
    #########
    <BLANKLINE>
    "Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";
    "Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";
    }

    r   c           	      ó   •‡‡— ‰                      t          | ‰	‰‰‰¬¦  «        ¦  «         ‰r‰‰k    rd S ‰                     t          | ‰‰‰¬¦  «        ¦  «         ˆˆˆˆ
fd„t	          | j        ¦  «        D ¦   «          d S )N)r<   r=   r>   )rN   r=   r>   c                 óT   •— g | ]$\  }} ‰|¦  «        ° ‰|‰d z   ‰|fz   ¦  «        ‘Œ%S )é   r   )r.   rI   ÚargrN   Údepthr=   Útraverses      €€€€r"   rK   z.dotprint.<locals>.traverse.<locals>.<listcomp>!  sG   ø€ Ð]Ð]Ð]±°°3ÐSWÐSWÐX[ÑS\ÔS\Ð]ˆˆ�#�u˜Q‘w  q d¡
Ñ	+Ô	+Ð]Ð]Ð]r#   )Úappendr@   ÚextendrP   rM   r   )Úer[   r=   rN   Úedgesr<   ÚmaxdepthÚnodesr>   r'   r\   s    ``€€€€€€€€r"   r\   zdotprint.<locals>.traverse  s—   øøø€ Ø�Š•W˜Q °)ÀÈVÐTÑTÔTÑUÔUÐUØð 	˜ Ò)Ð)ØˆFØ�Š•X˜a d°¸FÐCÑCÔCÑDÔDÐDØ]Ð]Ð]Ð]Ð]Ð]Ð]½)ÀAÄFÑ:KÔ:KÐ]Ñ]Ô]Ð]Ð]Ð]r#   r   ú
)r4   )Ú
graphstylerb   r`   )r   )Ú_graphstyleÚcopyr%   Útemplater5   r   )r&   r'   rN   ra   r>   r<   Úkwargsrd   r`   rb   r\   s    `````  @@@r"   r
   r
   º   sâ   øøøøøøøø€ õz ×!Ò!Ñ#Ô#€JØ×Ò�fÑÔÐà€EØ€Eð^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð ^ð €HˆT�1ÑÔÐå¥9¨ZÀ4Ð#HÑ#HÔ#HØ"Ÿiši¨Ñ.Ô.Ø"Ÿiši¨Ñ.Ô.ð0ð 0ñ 0ð 0r#   )F)r   )Úsympy.core.basicr   Úsympy.core.exprr   Úsympy.core.symbolr   Úsympy.core.numbersr   r   r   Úsympy.printing.reprr	   Ú__all__Údefault_stylesÚslotClassesr   r+   r5   r   r@   rP   rg   re   r
   r   r#   r"   ú<module>rq      s€  ðØ "Ð "Ð "Ð "Ð "Ð "Ø  Ð  Ð  Ð  Ð  Ð  Ø $Ð $Ð $Ð $Ð $Ð $Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø %Ð %Ð %Ð %Ð %Ð %àˆ,€ð �f yÐ1Ð1Ð2Ø	ˆW�gÐÐð€ð
 �w ¨%Ð0€ð<ð <ð <ð <ð~ (ð ð ð ð ð2
Jð 
Jð 
Jð 
Jð (°3¸BÀtð 7ð 7ð 7ð 7ð0 ;Ð:ÀÈ4ð Cð Cð Cð Cð4ð 	ð& ¨EÐ2Ð2€ð Ð BÐ BØ˜$¨#ðl0ð l0ð l0ð l0ð l0ð l0r#   