ó
    †~iÔq  ã                   ó   • S r SSKrSSKJr  SSKrSSKJr  SS/r " S S5      r	 " S	 S
\	5      r
 " S S\
5      r " S S\
5      r " S S\	5      r " S S\5      r " S S\5      r     SS jr\" SS5             SS j5       rS rS rg)z-
Text-based visual representations of graphs
é    N)Údefaultdict)Ú	open_fileÚgenerate_network_textÚwrite_network_textc                   ó$   • \ rS rSr\S 5       rSrg)Ú
BaseGlyphsé   c                 ó˜   • [        U 5       Vs0 s H/  nUR                  S5      (       a  M  US:w  d  M#  U[        X5      _M1     sn$ s  snf )NÚ_Úas_dict)ÚdirÚ
startswithÚgetattr)ÚclsÚas     ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/readwrite/text.pyr   ÚBaseGlyphs.as_dict   sP   € ô ˜”Xó
â�Ø—<‘< ×$ó à)*¨i©ó ˆAŒw�s‹ÒÙñ
ð 	
ùò 
s   ŽA¬A´A© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Úclassmethodr   Ú__static_attributes__r   ó    r   r   r      s   † Øñ
ó ó
r   r   c                   ój   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S'   S	r
\\S
'   Sr\\S'   Srg)ÚAsciiBaseGlyphsé   Ú+Úemptyz+-- Únewtree_lastÚnewtree_midú    Úendof_forestz:   Úwithin_forestz|   Úwithin_treer   N©r   r   r   r   r    ÚstrÚ__annotations__r!   r"   r$   r%   r&   r   r   r   r   r   r      s>   ‡ Ø€Eˆ3ÓØ€L�#ÓØ€K�ÓØ€L�#ÓØ€M�3ÓØ€K�Ör   r   c                   óN   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   S
r
g)ÚAsciiDirectedGlyphsé!   zL-> Úlastz|-> Úmidz<-ÚbackedgeÚ!Úvertical_edger   N©r   r   r   r   r-   r(   r)   r.   r/   r1   r   r   r   r   r+   r+   !   s*   ‡ Ø€Dˆ#ÓØ€CˆÓØ€HˆcÓØ€M�3Ör   r+   c                   óN   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   S
r
g)ÚAsciiUndirectedGlyphsé(   zL-- r-   z|-- r.   Ú-r/   Ú|r1   r   Nr2   r   r   r   r4   r4   (   s*   ‡ Ø€Dˆ#ÓØ€CˆÓØ€HˆcÓØ€M�3Ör   r4   c                   ój   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   S
r
\\S'   Sr\\S'   Srg)ÚUtfBaseGlyphsé/   u   â•™r    u
   â•™â”€â”€ r!   u
   â•Ÿâ”€â”€ r"   r#   r$   u   â•Ž   r%   u   â”‚   r&   r   Nr'   r   r   r   r9   r9   /   s@   ‡ ð €Eˆ3ÓØ$€L�#Ó$Ø#€K�Ó#Ø€L�#ÓØ!€M�3Ó!Ø€K�Ör   r9   c                   óN   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   S
r
g)ÚUtfDirectedGlyphsé;   u
   â””â”€â•¼ r-   u
   â”œâ”€â•¼ r.   u   â•¾r/   u   â•½r1   r   Nr2   r   r   r   r<   r<   ;   ó*   ‡ Ø€Dˆ#ÓØ€CˆÓØ€HˆcÓØ€M�3Ör   r<   c                   óN   • \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S	'   S
r
g)ÚUtfUndirectedGlyphséB   u
   â””â”€â”€ r-   u
   â”œâ”€â”€ r.   u   â”€r/   u   â”‚r1   r   Nr2   r   r   r   r@   r@   B   r>   r   r@   c              #   ól
  ^(#   • SSK Jm(Jn   " U(4S jSU5      nSnU R                  5       n	U	(       a,  U(       a  [        O[
        n
U R                  nU R                  nO+U(       a  [        O[        n
U R                  nU R                  n[        U[        5      (       a  UnOU(       a  SnOSnUS:X  a  U
R                  S-   v •  g[        U R                  5      S:X  a  U
R                  v •  gUc  [!        U 5      n[        U5      S	-
  n[#        U5       VVs/ s H  u  nnU" SU/ Xþ:H  S
5      PM     snnSSS2   n[%        S 5      n['        5       nU(       Ga¾  UR)                  5       u  nnnnnU[*        La‹  UU;   nU(       a  UU==   S	-  ss'   U(       aQ  UU   (       aG  UbD  SnU" U[*        UUS
5      nUR-                  U5        S
nU" UUUUU5      nUR-                  U5        M˜  U(       a  M¡  UR/                  U5        U(       dK  U(       a#  S
nUU
R0                  /-   nUU
R2                  /-   nOuUU
R4                  /-   nUU
R6                  /-   nOTU(       a  UnUnOHU(       a!  UU
R8                  /-   nUU
R2                  /-   nO UU
R:                  /-   nUU
R<                  /-   nU[*        L a  SnSn/ nGO’Ub)  [        U R                  U   R?                  UU5      5      nO[        U5      nUb   U R                  U   R?                  US
5      n OS
n U	(       a  [A        UU   5      nU1n!O#UU    V"s/ s H  n"U"U;  d  M  U"PM     nn"1 UkUin!Ub#  [        U5      US	-
  :X  a  U(       a  [*        /nU1n!U (       a  U(       a  [*        /nU1n!UU    V#s/ s H  n#U#U!;  d  M  U#PM     n$n#U$(       a–  UbI  SRC                  U$ V#s/ s H+  n#[        U R                  U#   R?                  UU#5      5      PM-     sn#5      n%O+SRC                  U$ V#s/ s H  n#[        U#5      PM     sn#5      n%SRC                  SU
RD                  U%/5      nOSnU(       a!  SRC                  UU
RF                  /-   5      v •  SRC                  UUU/-   5      v •  U(       a:  U	(       a  [        ['        U5      5      n&O[        ['        U5      U1-
  5      n&U&S	:H  n'OS
n'[#        USSS2   5       H(  u  nn"US:H  nU" UU"UUU'5      nUR-                  U5        M*     U(       a  GM½  ggs  snnf s  sn"f s  sn#f s  sn#f s  sn#f 7f)u¬  Generate lines in the "network text" format

This works via a depth-first traversal of the graph and writing a line for
each unique node encountered. Non-tree edges are written to the right of
each node, and connection to a non-tree edge is indicated with an ellipsis.
This representation works best when the input graph is a forest, but any
graph can be represented.

This notation is original to networkx, although it is simple enough that it
may be known in existing literature. See #5602 for details. The procedure
is summarized as follows:

1. Given a set of source nodes (which can be specified, or automatically
discovered via finding the (strongly) connected components and choosing one
node with minimum degree from each), we traverse the graph in depth first
order.

2. Each reachable node will be printed exactly once on it's own line.

3. Edges are indicated in one of four ways:

    a. a parent "L-style" connection on the upper left. This corresponds to
    a traversal in the directed DFS tree.

    b. a backref "<-style" connection shown directly on the right. For
    directed graphs, these are drawn for any incoming edges to a node that
    is not a parent edge. For undirected graphs, these are drawn for only
    the non-parent edges that have already been represented (The edges that
    have not been represented will be handled in the recursive case).

    c. a child "L-style" connection on the lower right. Drawing of the
    children are handled recursively.

    d. if ``vertical_chains`` is true, and a parent node only has one child
    a "vertical-style" edge is drawn between them.

4. The children of each node (wrt the directed DFS tree) are drawn
underneath and to the right of it. In the case that a child node has already
been drawn the connection is replaced with an ellipsis ("...") to indicate
that there is one or more connections represented elsewhere.

5. If a maximum depth is specified, an edge to nodes past this maximum
depth will be represented by an ellipsis.

6. If a node has a truthy "collapse" value, then we do not traverse past
that node.

Parameters
----------
graph : nx.DiGraph | nx.Graph
    Graph to represent

with_labels : bool | str
    If True will use the "label" attribute of a node to display if it
    exists otherwise it will use the node value itself. If given as a
    string, then that attribute name will be used instead of "label".
    Defaults to True.

sources : List
    Specifies which nodes to start traversal from. Note: nodes that are not
    reachable from one of these sources may not be shown. If unspecified,
    the minimal set of nodes needed to reach all others will be used.

max_depth : int | None
    The maximum depth to traverse before stopping. Defaults to None.

ascii_only : Boolean
    If True only ASCII characters are used to construct the visualization

vertical_chains : Boolean
    If True, chains of nodes will be drawn vertically when possible.

Yields
------
str : a line of generated text

Examples
--------
>>> graph = nx.path_graph(10)
>>> graph.add_node("A")
>>> graph.add_node("B")
>>> graph.add_node("C")
>>> graph.add_node("D")
>>> graph.add_edge(9, "A")
>>> graph.add_edge(9, "B")
>>> graph.add_edge(9, "C")
>>> graph.add_edge("C", "D")
>>> graph.add_edge("C", "E")
>>> graph.add_edge("C", "F")
>>> nx.write_network_text(graph)
â•™â”€â”€ 0
    â””â”€â”€ 1
        â””â”€â”€ 2
            â””â”€â”€ 3
                â””â”€â”€ 4
                    â””â”€â”€ 5
                        â””â”€â”€ 6
                            â””â”€â”€ 7
                                â””â”€â”€ 8
                                    â””â”€â”€ 9
                                        â”œâ”€â”€ A
                                        â”œâ”€â”€ B
                                        â””â”€â”€ C
                                            â”œâ”€â”€ D
                                            â”œâ”€â”€ E
                                            â””â”€â”€ F
>>> nx.write_network_text(graph, vertical_chains=True)
â•™â”€â”€ 0
    â”‚
    1
    â”‚
    2
    â”‚
    3
    â”‚
    4
    â”‚
    5
    â”‚
    6
    â”‚
    7
    â”‚
    8
    â”‚
    9
    â”œâ”€â”€ A
    â”œâ”€â”€ B
    â””â”€â”€ C
        â”œâ”€â”€ D
        â”œâ”€â”€ E
        â””â”€â”€ F
r   ©ÚAnyÚ
NamedTuplec                   óN   >• \ rS rSr%  Y \S'    Y \S'   \\S'   \\S'   \\S'   Srg)	Ú)generate_network_text.<locals>.StackFrameéØ   ÚparentÚnodeÚindentsÚthis_islastÚthis_verticalr   N)r   r   r   r   r)   ÚlistÚboolr   ©rD   s   €r   Ú
StackFramerG   Ø   s   ø‡ Ù‹Ù‹	Ø‹ØÓØÖr   rQ   ÚcollapseÚlabelNz ...é   Féÿÿÿÿc                  ó   • g)Nr   r   r   r   r   Ú<lambda>Ú'generate_network_text.<locals>.<lambda>	  s   € °1r   TÚ ú, Ú )$ÚtypingrD   rE   Úis_directedr+   r<   ÚsuccÚpredr4   r@   ÚadjÚ
isinstancer(   r    ÚlenÚnodesÚ_find_sourcesÚ	enumerater   ÚsetÚpopÚEllipsisÚappendÚaddr!   r$   r"   r%   r-   r.   r&   ÚgetrN   Újoinr/   r1   ))ÚgraphÚwith_labelsÚsourcesÚ	max_depthÚ
ascii_onlyÚvertical_chainsrE   rQ   Úcollapse_attrr]   Úglyphsr^   r_   Ú
label_attrÚlast_idxÚidxrJ   ÚstackÚnum_skipped_childrenÚ
seen_nodesrI   rK   rL   rM   ÚskipÚnext_islastÚ	try_frameÚthis_prefixÚnext_prefixrS   ÚsuffixÚchildrenrR   Úhandled_parentsÚchildÚpÚother_parentsÚother_parents_labelsÚnum_childrenÚnext_is_verticalrD   s)                                           @r   r   r   I   s7  øé € ÷Z '÷�Zô ð €Mà×#Ñ#Ó%€KæÞ(2Õ$Ô8IˆØ�z‰zˆØ�z‰z‰æ*4Õ&Ô:MˆØ�y‰yˆØ�y‰yˆä�+œs×#Ñ#Ø ‰
Þ	Ø‰
àˆ
à�Aƒ~Ø�l‰l˜VÑ#Ó#Ü	ˆU�[‰[Ó	˜QÓ	Ø�l‰lÓð ‰?Ü# EÓ*ˆGô �w“< !Ñ#ˆô ' wÔ/ô
â/‘	��Tñ �t˜T 2¨©¸%Ö@Ù/ò
ñ ˆBˆ$ñˆô
  +©9Ó5ÐÜ“Uˆ
ßØ@EÇ	Á	ÃÑ=ˆF�D˜' ;°àœ8Ò#Ø˜zÑ)�Þà(¨Ó0°AÑ5Ó0æð ,¨F×3¸Ñ8Jà&*˜Ù$.Ø ¤(¨G°[À%ó%˜	ð Ÿ™ YÔ/ð ',˜Ù$.Ø" D¨'°;Àó%˜	ð Ÿ™ YÔ/Ù æÙØ—‘˜tÔ$æö Ø$)�MØ")¨V×-@Ñ-@Ð,AÑ"A�KØ")¨V×-@Ñ-@Ð,AÑ"A‘Kà")¨V×-?Ñ-?Ð,@Ñ"@�KØ")¨V×-AÑ-AÐ,BÑ"B‘Kö !Ø")�KØ")‘Kæ"Ø&-°·±°Ñ&=˜Ø&-°×1DÑ1DÐ0EÑ&E™à&-°·±°Ñ&<˜Ø&-°×1CÑ1CÐ0DÑ&D˜à”xÒØ�Ø�Ø’àÑ)Ü §¡¨DÑ 1× 5Ñ 5°jÀ$Ó GÓH‘Eä ›I�Eð !Ñ,Ø$Ÿ{™{¨4Ñ0×4Ñ4°]ÀEÓJ‘Hà$�Hö
 ô  $ D¨¡JÓ/�Hð (. h‘Oð
 ,0°ª:ó Ú+5 %¸ÀjÑ9PŸ©:ð ð  ð ':¨Ð&9°&Ð&9�OàÑ(¬S°«\¸YÈ¹]Ó-JæÜ$, :˜Ø'- h�OææÜ$, :˜Ø'- h�Oð -1°ªJÓ SªJ q¸!À?Ñ:R§©J�Ð SÞ Ø!Ñ-Ø/3¯y©yñ *7óâ)6 Aô !$ E§K¡K°¡N×$6Ñ$6°zÀ1Ó$EÖ FÙ)6ñó0Ñ,ð 04¯y©yÙ-:Ó;ª]¨œS žV©]Ñ;ó0Ð,ð !ŸX™X r¨6¯?©?Ð<PÐ&QÓR‘Fà�Fö Ø—g‘g˜k¨V×-AÑ-AÐ,BÑBÓCÒCà—'‘'˜+¨°¨Ñ7Ó8Ò8æÞÜ#&¤s¨8£}Ó#5‘Lä#&¤s¨8£}¸°xÑ'?Ó#@�Lð $0°1Ñ#4Ñ à#(Ð ô (¨±°2°©Ö7‘
��UØ! Q™h�Ù&Ø˜% ¨kÐ;Kó�	ð —‘˜YÖ'ñ 8÷g ‹eùó
ùò| ùò. !Tùòùò <ùsW   ƒDT4ÄTÄ3HT4Ì8
T ÍT ÍAT4Î
T%Î'T%Î-T4Ï2T*Ï:T4ÐT/Ð&C/T4ÔT4rT   Úwc           	      ó  • Uc  [         R                  R                  nOE[        US5      (       a  UR                  nO'[	        U5      (       a  UnO[        [        U5      5      e[        U UUUUUS9 H  n	U" X–-   5        M     g)už  Creates a nice text representation of a graph

This works via a depth-first traversal of the graph and writing a line for
each unique node encountered. Non-tree edges are written to the right of
each node, and connection to a non-tree edge is indicated with an ellipsis.
This representation works best when the input graph is a forest, but any
graph can be represented.

Parameters
----------
graph : nx.DiGraph | nx.Graph
    Graph to represent

path : string or file or callable or None
   Filename or file handle for data output.
   if a function, then it will be called for each generated line.
   if None, this will default to "sys.stdout.write"

with_labels : bool | str
    If True will use the "label" attribute of a node to display if it
    exists otherwise it will use the node value itself. If given as a
    string, then that attribute name will be used instead of "label".
    Defaults to True.

sources : List
    Specifies which nodes to start traversal from. Note: nodes that are not
    reachable from one of these sources may not be shown. If unspecified,
    the minimal set of nodes needed to reach all others will be used.

max_depth : int | None
    The maximum depth to traverse before stopping. Defaults to None.

ascii_only : Boolean
    If True only ASCII characters are used to construct the visualization

end : string
    The line ending character

vertical_chains : Boolean
    If True, chains of nodes will be drawn vertically when possible.

Examples
--------
>>> graph = nx.balanced_tree(r=2, h=2, create_using=nx.DiGraph)
>>> nx.write_network_text(graph)
â•™â”€â”€ 0
    â”œâ”€â•¼ 1
    â”‚   â”œâ”€â•¼ 3
    â”‚   â””â”€â•¼ 4
    â””â”€â•¼ 2
        â”œâ”€â•¼ 5
        â””â”€â•¼ 6

>>> # A near tree with one non-tree edge
>>> graph.add_edge(5, 1)
>>> nx.write_network_text(graph)
â•™â”€â”€ 0
    â”œâ”€â•¼ 1 â•¾ 5
    â”‚   â”œâ”€â•¼ 3
    â”‚   â””â”€â•¼ 4
    â””â”€â•¼ 2
        â”œâ”€â•¼ 5
        â”‚   â””â”€â•¼  ...
        â””â”€â•¼ 6

>>> graph = nx.cycle_graph(5)
>>> nx.write_network_text(graph)
â•™â”€â”€ 0
    â”œâ”€â”€ 1
    â”‚   â””â”€â”€ 2
    â”‚       â””â”€â”€ 3
    â”‚           â””â”€â”€ 4 â”€ 0
    â””â”€â”€  ...

>>> graph = nx.cycle_graph(5, nx.DiGraph)
>>> nx.write_network_text(graph, vertical_chains=True)
â•™â”€â”€ 0 â•¾ 4
    â•½
    1
    â•½
    2
    â•½
    3
    â•½
    4
    â””â”€â•¼  ...

>>> nx.write_network_text(graph, vertical_chains=True, ascii_only=True)
+-- 0 <- 4
    !
    1
    !
    2
    !
    3
    !
    4
    L->  ...

>>> graph = nx.generators.barbell_graph(4, 2)
>>> nx.write_network_text(graph, vertical_chains=False)
â•™â”€â”€ 4
    â”œâ”€â”€ 5
    â”‚   â””â”€â”€ 6
    â”‚       â”œâ”€â”€ 7
    â”‚       â”‚   â”œâ”€â”€ 8 â”€ 6
    â”‚       â”‚   â”‚   â””â”€â”€ 9 â”€ 6, 7
    â”‚       â”‚   â””â”€â”€  ...
    â”‚       â””â”€â”€  ...
    â””â”€â”€ 3
        â”œâ”€â”€ 0
        â”‚   â”œâ”€â”€ 1 â”€ 3
        â”‚   â”‚   â””â”€â”€ 2 â”€ 0, 3
        â”‚   â””â”€â”€  ...
        â””â”€â”€  ...
>>> nx.write_network_text(graph, vertical_chains=True)
â•™â”€â”€ 4
    â”œâ”€â”€ 5
    â”‚   â”‚
    â”‚   6
    â”‚   â”œâ”€â”€ 7
    â”‚   â”‚   â”œâ”€â”€ 8 â”€ 6
    â”‚   â”‚   â”‚   â”‚
    â”‚   â”‚   â”‚   9 â”€ 6, 7
    â”‚   â”‚   â””â”€â”€  ...
    â”‚   â””â”€â”€  ...
    â””â”€â”€ 3
        â”œâ”€â”€ 0
        â”‚   â”œâ”€â”€ 1 â”€ 3
        â”‚   â”‚   â”‚
        â”‚   â”‚   2 â”€ 0, 3
        â”‚   â””â”€â”€  ...
        â””â”€â”€  ...

>>> graph = nx.complete_graph(5, create_using=nx.Graph)
>>> nx.write_network_text(graph)
â•™â”€â”€ 0
    â”œâ”€â”€ 1
    â”‚   â”œâ”€â”€ 2 â”€ 0
    â”‚   â”‚   â”œâ”€â”€ 3 â”€ 0, 1
    â”‚   â”‚   â”‚   â””â”€â”€ 4 â”€ 0, 1, 2
    â”‚   â”‚   â””â”€â”€  ...
    â”‚   â””â”€â”€  ...
    â””â”€â”€  ...

>>> graph = nx.complete_graph(3, create_using=nx.DiGraph)
>>> nx.write_network_text(graph)
â•™â”€â”€ 0 â•¾ 1, 2
    â”œâ”€â•¼ 1 â•¾ 2
    â”‚   â”œâ”€â•¼ 2 â•¾ 0
    â”‚   â”‚   â””â”€â•¼  ...
    â”‚   â””â”€â•¼  ...
    â””â”€â•¼  ...
NÚwrite)rn   ro   rp   rq   rr   )ÚsysÚstdoutr‹   ÚhasattrÚcallableÚ	TypeErrorÚtyper   )
rm   Úpathrn   ro   rp   rq   Úendrr   Ú_writeÚlines
             r   r   r   ¦  sy   € ðJ �|ä—‘×!Ñ!‰Ü	��w×	Ñ	à—‘‰Ü	�$�‰à‰äœ˜T›
Ó#Ð#ä%ØØØØØØ'ôˆñ 	ˆt‰zÖòr   c                 óŠ  ^ • T R                  5       (       aâ  [        [        R                  " T 5      5      n[        R                  " T U5      nUR                  5        Vs0 s H  o3/ _M     nnUR                  S   nT R
                   H  nXV   nXC   R                  U5        M     / nUR                  5        H;  nUR                  U   S:X  d  M  XC   n[        UU 4S jS9n	UR                  U	5        M=     U$ [        R                  " T 5       V
s/ s H  n
[        U
U 4S jS9PM     nn
[        UU 4S jS9nU$ s  snf s  sn
f )zJ
Determine a minimal set of nodes such that the entire graph is reachable
Úmappingr   c                 ó"   >• TR                   U    $ ©N)Ú	in_degree©Únrm   s    €r   rW   Ú_find_sources.<locals>.<lambda>z  s   ø€ ¨e¯o©o¸aÒ.@r   )Úkeyc                 ó"   >• TR                   U    $ r™   ©Údegreer›   s    €r   rW   r�   €  s   ø€  %§,¡,¨q¢/r   c                 ó"   >• TR                   U    $ r™   r    r›   s    €r   rW   r�   ƒ  s   ø€ °·±¸Q²r   )r]   rN   ÚnxÚstrongly_connected_componentsÚcondensationrc   rm   ri   rš   ÚminÚconnected_componentsÚsorted)rm   ÚsccsÚ	scc_graphÚsnÚsupernode_to_nodesr—   rœ   ro   ÚsccrJ   Úccs   `          r   rd   rd   b  s8  ø€ ð ×Ñ×Ñä”B×4Ò4°UÓ;Ó<ˆô —O’O E¨4Ó0ˆ	Ø/8¯©Ô/@ÓAÒ/@¨ "šfÑ/@ÐÐAð —/‘/ )Ñ,ˆØ—”ˆAØ‘ˆBØÑ"×)Ñ)¨!Ö,ñ ð ˆØ—/‘/Ö#ˆBØ×"Ñ" 2Ñ&¨!Õ+Ø(Ñ,�Ü˜3Ô$@ÑA�Ø—‘˜tÖ$ñ	 $ð €Nô ×-Ò-¨eÔ4ó
â4�ô �Ô1Ô2Ù4ð 	ð 
ô ˜Ô&?Ñ@ˆØ€Nùò+ Bùò 
s   ÁD;ÄE c                 ó^
  ^(^)• SSK Jn  SSKJm(Jn   " U(4S jSU5      n[        U 5      nSnSn/ n [        U5      nUR                  U5        US   n	U	[        R                  [        R                  S   [        R                  S   1;   a  SnOJU	[        R                  [        R                  S   [        R                  S   1;   a  SnO[        S	U	 35      eU(       a)  [        R!                  5       n
["        R!                  5       nO([$        R!                  5       n
[&        R!                  5       n[)        U
R+                  5       5      n[)        UR+                  5       5      n/ nU H9  nUnU Vs/ s H  nUU;   d  M  UPM     nnU(       a  M(  UR                  U5        M;     / nU H9  nUnU Vs/ s H  nUU;   d  M  UPM     nnU(       a  M(  UR                  U5        M;     U HP  m)UR                  T)5        [-        U)4S
 jU 5       5      (       a  Sn  O"[-        U)4S jU 5       5      (       d  MN  Sn  O   Uc  SnU(       a  U
OUnSUS   -   S-   nU" Xt5      n/ n/ nSn[/        5       nU" USS5      /nU GH!  m)T)US   :X  a  SnM  UT);   a�  T)R1                  U5      u  nnUR1                  S5       Vs/ s H  nUR3                  5       PM     nnUR5                  5       nUR7                  SS5      u  n n!U!R3                  5       n!UR9                  U Vs/ s H  nUU!4PM	     sn5        O%T)R7                  SS5      u  n n!U!R3                  5       n!UR;                  5       n"U!US   ;   a2  U" U"R<                  U"R>                  S5      n#UR                  U#5        GM$  [A        U 5      n$U" U!U$S5      n%U"RB                  (       a  OFU%R>                  U"R>                  ::  a,  UR;                  5       n"U%R>                  U"R>                  ::  a  M,  U!S:X  a  UR                  U"5        GM«  UR                  U"5        UR                  U%5        UR                  U%R<                  5        U"R<                  ULd  GMú  UR                  U"R<                  U%R<                  45        GM$     U(       a  [A        U5      S:X  d   eU(       a  [D        RF                  O[D        RH                  n&U&" 5       n'U'RK                  U5        U'RM                  U5        U'$ ! [         a     GN?f = fs  snf s  snf s  snf s  snf )a]  Reconstructs a graph from a network text representation.

This is mainly used for testing.  Network text is for display, not
serialization, as such this cannot parse all network text representations
because node labels can be ambiguous with the glyphs and indentation used
to represent edge structure. Additionally, there is no way to determine if
disconnected graphs were originally directed or undirected.

Parameters
----------
lines : list or iterator of strings
    Input data in network text format

Returns
-------
G: NetworkX graph
    The graph corresponding to the lines in network text format.
r   )ÚchainrC   c                   ó>   >• \ rS rSr%  Y \S'   \\S'   \S-  \S'   Srg)Ú,_parse_network_text.<locals>.ParseStackFramei�  rJ   ÚindentNÚhas_vertical_childr   )r   r   r   r   r)   Úintr   rP   s   €r   ÚParseStackFramer²   �  s   ø‡ Ù‹	Ø‹Ø $™JÖ&r   r¶   NFTzUnexpected first character: c              3   ó,   >#   • U  H	  oT;   v •  M     g 7fr™   r   ©Ú.0Úitemr•   s     €r   Ú	<genexpr>Ú&_parse_network_text.<locals>.<genexpr>â  s   øé € ÐEÒ(D �tŽ|Ò(Dùó   ƒc              3   ó,   >#   • U  H	  oT;   v •  M     g 7fr™   r   r¸   s     €r   r»   r¼   å  s   øé € ÐEÒ*D $˜–Ò*Dùr½   r[   r/   rU   r    rZ   rT   r1   z...)'Ú	itertoolsr°   r\   rD   rE   ÚiterÚnextri   r9   r    r"   r!   r   ÚAssertionErrorÚStopIterationr+   r   r4   r<   r@   rf   ÚvaluesÚanyÚobjectÚsplitÚstripÚrstripÚrsplitÚextendrg   rJ   r³   rb   r´   r£   ÚDiGraphÚGraphÚadd_nodes_fromÚadd_edges_from)*Úlinesr°   rE   r¶   Úinitial_line_iterÚis_asciir]   Úinitial_linesÚ
first_lineÚ
first_charÚdirected_glyphsÚundirected_glyphsÚdirected_itemsÚundirected_itemsÚunambiguous_directed_itemsrº   Úother_itemsÚotherÚother_supersetsÚunambiguous_undirected_itemsrt   Úbackedge_symbolÚparsing_line_iterÚedgesrc   Úis_emptyÚnoparentrx   Ú	node_partÚbackedge_partÚuÚbackedge_nodesÚprefixrJ   ÚprevÚmodified_prevr³   Úcurrr   ÚnewrD   r•   s*                                           @@r   Ú_parse_network_textrí   ‡  s×  ù€ õ&  ß&÷'˜*ô 'ô
 ˜U›Ðà€HØ€Kð €MðNÜÐ+Ó,ˆ
ð 	×Ñ˜ZÔ(à ‘]ˆ
ØÜ×ÑÜ×%Ñ% aÑ(Ü×&Ñ& qÑ)ð
ó 
ð
 ‰HØÜ×!Ñ!Ü×'Ñ'¨Ñ*Ü×(Ñ(¨Ñ+ð
ó 
ð
 ‰Hä Ð#?À
¸|Ð!LÓMÐMæÜ-×5Ñ5Ó7ˆÜ1×9Ñ9Ó;Ñä+×3Ñ3Ó5ˆÜ/×7Ñ7Ó9Ðô ˜×/Ñ/Ó1Ó2€NÜÐ,×3Ñ3Ó5Ó6ÐØ!#ÐÛˆØ&ˆÙ.9ÓKªk U¸TÀU¹]Ÿ5©kˆÐKßˆØ&×-Ñ-¨dÖ3ñ	 ð
 $&Ð Û ˆØ$ˆÙ.9ÓKªk U¸TÀU¹]Ÿ5©kˆÐKßˆØ(×/Ñ/°Ö5ñ	 !ó "ˆØ×Ñ˜TÔ"ÜÔEÑ(DÓE×EÑEØˆKÙÜÔEÑ*DÓE×EÓEØˆKÙñ "ð Ñàˆæ +‰_Ð1B€Fð ˜F :Ñ.Ñ.°Ñ4€Oñ ˜mÓ?Ðð €EØ€EØ€Hä‹x€Hñ ˜X r¨4Ó0Ð1€Eä!ˆØ�6˜'‘?Ó"ð ˆHÙà˜dÓ"à'+§z¡z°/Ó'BÑ$ˆI�}Ø1>×1DÑ1DÀTÔ1JÓKÒ1J¨A˜aŸg™gžiÑ1JˆNÐKà!×(Ñ(Ó*ˆIØ$×+Ñ+¨C°Ó3‰LˆF�DØ—:‘:“<ˆDà�L‰L©^Ó<ª^¨˜1˜d›)©^Ñ<Õ=ð  Ÿ;™; s¨AÓ.‰LˆF�DØ—:‘:“<ˆDà�y‰y‹{ˆà�6˜/Ñ*Ó*ñ ,Ø—	‘	Ø—‘ØóˆMð
 �L‰L˜Ô'Úô
 �V“ˆÙ˜t V¨TÓ2ˆà×"×"ð ð —+‘+ §¡Ó,Ø—y‘y“{�ð —+‘+ §¡Õ,ð �5‹=ð �L‰L˜×ð �L‰L˜ÔØ�L‰L˜Ôð �L‰L˜Ÿ™Ô#Ø�y‰y Õ(Ø—‘˜dŸi™i¨¯©Ð3×4ñK "öN ä�5‹z˜Q‹Ðˆö $Œ"�*Š*¬¯©€CÙ
‹%€CØ×Ñ�uÔØ×Ñ�uÔØ€JøôE ó ÚðüòJ Lùò Lùòb Lùò =s5   ±T
 Å/
TÅ=TÆ0
T Æ>T Ê8T%ÌT*
Ô

TÔT)TNNFF)NTNNFÚ
F)Ú__doc__rŒ   Úcollectionsr   Únetworkxr£   Únetworkx.utilsr   Ú__all__r   r   r+   r4   r9   r<   r@   r   r   rd   rí   r   r   r   Ú<module>rô      sÎ   ðñó Ý #ã Ý $à"Ð$8Ð
9€÷
ñ 
ô�jô ô˜/ô ô˜Oô ô	 �Jô 	 ô˜ô ô˜-ô ð ØØØØôZ(ñz
 ˆ1ˆcÓð 
ØØØØØØóxó ðxòv"óJLr   