U
    ?h                     @   sn  d Z ddlZdZdZee eed  ee e e eed  eed e e ed e ed ed eed  ee e ee ed  ed ee ed eed  e ed e e ee e ed eed e ed e eed  eed  e ee ed  ed ed  dZeee d	d
 dZ	dd e D Z
de
d< e Ze	 D ].\ZZedd Zeje
e eed d qTeeeD ]$\ZZeD ]Zeeje d< qqejedddZeD ]Zee d  d9  < qejeedd dd ejddD Zejeeed dd ZddlZej D ]Z!ee!ee! ks4t"q4e#d$dd dD  dS ) a  
==========
Morse Trie
==========

A prefix tree (aka a "trie") representing the Morse encoding of the alphabet.
A letter can be encoded by tracing the path from the corresponding node in the
tree to the root node, reversing the order of the symbols encountered along
the path.
    Nu   •u   —         )abcdefghijklmnopqrstuvwxyzc                 C   s   t | d | d fS )N   )len)item r"   p/var/www/html/venv/lib/python3.8/site-packages/../../../share/doc/networkx-3.1/examples/graph/plot_morse_trie.py<lambda>4       r$   )keyc                 C   s   i | ]\}}||qS r"   r"   ).0r   r   r"   r"   r#   
<dictcomp>8   s      r(    )charlayer
horizontal)Z
subset_keyalignT)posZwith_labelsc                 C   s   i | ]\}}}||f|qS r"   r"   )r'   r   r   r   r"   r"   r#   r(   M   s      r+   )data)Zedge_labelsc                 C   s6   t t| }t| |  d }|dkr2t|| S |S )Nr+   r)   )nextGZpredecessorsmorse_encode)letterpredsymbolr"   r"   r#   r3   S   s
    r3    c                 C   s   g | ]}t |qS r"   )r3   )r'   Zltrr"   r"   r#   
<listcomp>a   s     r8   Zilovenetworkx)%__doc__ZnetworkxnxdotdashZmorse_direct_mappingdictsorteditemsZmorse_mapping_sortedreverse_mappingZDiGraphr2   noder+   r5   Zadd_edge	enumerateZtopological_generationsr   r,   r   ZnodesZmultipartite_layoutr/   r   ZdrawedgesZelabelsZdraw_networkx_edge_labelsr3   stringascii_lowercaser4   AssertionErrorprintjoinr"   r"   r"   r#   <module>   sj   









!	
