ó
    †~iÙy  ã                   ór  • S r SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SSKrSSKJr  SS	KJr  / S
QrS rS rS r\" SSS9\R4                  " SSS9SS j5       5       r\R4                  " SSS9SS j5       r " S S\
5      r " S S\5      rSrS r S r!S S jr"\" SSS9S S j5       r#g)!aÕ  
Read graphs in GML format.

"GML, the Graph Modelling Language, is our proposal for a portable
file format for graphs. GML's key features are portability, simple
syntax, extensibility and flexibility. A GML file consists of a
hierarchical key-value lists. Graphs can be annotated with arbitrary
data structures. The idea for a common file format was born at the
GD'95; this proposal is the outcome of many discussions. GML is the
standard file format in the Graphlet graph editor system. It has been
overtaken and adapted by several other systems for drawing graphs."

GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
You will need to give some thought into how the exported data should
interact with different languages and even different Python versions.
Re-importing from gml is also a concern.

Without specifying a `stringizer`/`destringizer`, the code is capable of
writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
specification.  For writing other data types, and for reading data other
than `str` you need to explicitly supply a `stringizer`/`destringizer`.

For additional documentation on the GML file format, please see the
`GML website <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.

Several example graphs in GML format may be found on Mark Newman's
`Network data page <http://www-personal.umich.edu/~mejn/netdata/>`_.
é    N)Úliteral_eval)Údefaultdict)ÚEnum)ÚStringIO)ÚAnyÚ
NamedTuple)ÚNetworkXError)Ú	open_file)Úread_gmlÚ	parse_gmlÚgenerate_gmlÚ	write_gmlc                 óz   • S n[         R                  " SX5      n [        U [        5      (       a  U $ [        U 5      $ )z£Use XML character references to escape characters.

Use XML character references for unprintable or non-ASCII
characters, double quotes and ampersands in a string
c                 óX   • U R                  S5      nS[        [        U5      5      -   S-   $ )Nr   z&#Ú;)ÚgroupÚstrÚord)ÚmÚchs     ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/readwrite/gml.pyÚfixupÚescape.<locals>.fixup5   s'   € Ø�W‰W�Q‹ZˆØ”cœ#˜b›'“lÑ" SÑ(Ð(ó    z[^ -~]|[&"])ÚreÚsubÚ
isinstancer   ©Útextr   s     r   Úescaper    .   s4   € ò)ô �6Š6�- Ó-€DÜ˜d¤C×(Ñ(ˆ4Ð7¬c°$«iÐ7r   c                 ó6   • S n[         R                  " SX5      $ )z?Replace XML character references with the referenced charactersc                 ó   • U R                  S5      nUS   S:X  a(  US   S:X  a  [        USS S5      nO&[        USS 5      nO [        R                  USS    n [        U5      $ ! [         a    Us $ f = f! [        [        4 a    Us $ f = f)	Nr   é   Ú#é   Úxé   éÿÿÿÿé   )r   ÚintÚhtmlentitydefsÚname2codepointÚKeyErrorÚchrÚ
ValueErrorÚOverflowError)r   r   Úcodes      r   r   Úunescape.<locals>.fixup@   s    € Ø�w‰w�q‹zˆØ�‰7�c‹>à�A‰w˜#‹~Ü˜4  "˜: rÓ*‘ä˜4  "˜:“‘ðÜ%×4Ñ4°T¸!¸B°ZÑ@�ð	Ü�t“9Ðøô ó Ø’ðûô œMÐ*ó 	ØŠKð	ús$   ÁA& Á
A8 Á&A5Á4A5Á8BÂBz,&(?:[0-9A-Za-z]+|#(?:[0-9]+|x[0-9A-Fa-f]+));)r   r   r   s     r   Úunescaper3   =   s   € òô& �6Š6Ð@À%ÓNÐNr   c                 óª   • [        U [        5      (       a  U n [        U 5      $ [	        U < S35      e! [         a  n[	        U< S35      UeSnAff = f)zôConvert a Python literal to the value it represents.

Parameters
----------
rep : string
    A Python literal.

Returns
-------
value : object
    The value of the Python literal.

Raises
------
ValueError
    If `rep` is not a Python literal.
z is not a valid Python literalNú is not a string)r   r   r   ÚSyntaxErrorr/   )ÚrepÚorig_repÚerrs      r   Úliteral_destringizerr:   V   sf   € ô$ �#”s×ÑØˆð	UÜ Ó$Ð$ô ˜C™7Ð"2Ð3Ó4Ð4øô ó 	UÜ ™|Ð+IÐJÓKÐQTÐTûð	Uús   ™
3 ³
A½AÁAÚrb)ÚmodeT)ÚgraphsÚreturns_graphc                 ó0   • S n[        U" U 5      X5      nU$ )a@  Read graph in GML format from `path`.

Parameters
----------
path : file or string
    Filename or file handle to read.
    Filenames ending in .gz or .bz2 will be decompressed.

label : string, optional
    If not None, the parsed nodes will be renamed according to node
    attributes indicated by `label`. Default value: 'label'.

destringizer : callable, optional
    A `destringizer` that recovers values stored as strings in GML. If it
    cannot convert a string to a value, a `ValueError` is raised. Default
    value : None.

Returns
-------
G : NetworkX graph
    The parsed graph.

Raises
------
NetworkXError
    If the input cannot be parsed.

See Also
--------
write_gml, parse_gml
literal_destringizer

Notes
-----
GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
specification.  For writing other data types, and for reading data other
than `str` you need to explicitly supply a `stringizer`/`destringizer`.

For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.

See the module docstring :mod:`networkx.readwrite.gml` for more details.

Examples
--------
>>> G = nx.path_graph(4)
>>> nx.write_gml(G, "test_path4.gml")

GML values are interpreted as strings by default:

>>> H = nx.read_gml("test_path4.gml")
>>> H.nodes
NodeView(('0', '1', '2', '3'))

When a `destringizer` is provided, GML values are converted to the provided type.
For example, integer nodes can be recovered as shown below:

>>> J = nx.read_gml("test_path4.gml", destringizer=int)
>>> J.nodes
NodeView((0, 1, 2, 3))

c              3   óð   #   • U  HN  n UR                  S5      n[        U[        5      (       d  [	        U 5      n U(       a  US   S:X  a  US S nUv •  MP     g ! [         a  n[        S5      UeS nAff = f7f)NÚasciiúinput is not ASCII-encodedr(   Ú
)ÚdecodeÚUnicodeDecodeErrorr	   r   r   )ÚlinesÚliner9   s      r   Úfilter_linesÚread_gml.<locals>.filter_lines·   sz   é € ÛˆDðKØ—{‘{ 7Ó+�ô ˜d¤C×(Ñ(Ü˜E›
�Þ˜˜R™ DÓ(Ø˜C˜R�y�ØŒJò øô &ó KÜ#Ð$@ÓAÀsÐJûðKüs'   ‚A6‰Aš>A6Á
A3Á"A.Á.A3Á3A6©Úparse_gml_lines)ÚpathÚlabelÚdestringizerrH   ÚGs        r   r   r   r   s    € òJ
ô 	™ TÓ*¨EÓ@€AØ€Hr   c                 ó>   ^• S mU4S jn[        U" U 5      X5      nU$ )a£  Parse GML graph from a string or iterable.

Parameters
----------
lines : string or iterable of strings
   Data in GML format.

label : string, optional
    If not None, the parsed nodes will be renamed according to node
    attributes indicated by `label`. Default value: 'label'.

destringizer : callable, optional
    A `destringizer` that recovers values stored as strings in GML. If it
    cannot convert a string to a value, a `ValueError` is raised. Default
    value : None.

Returns
-------
G : NetworkX graph
    The parsed graph.

Raises
------
NetworkXError
    If the input cannot be parsed.

See Also
--------
write_gml, read_gml

Notes
-----
This stores nested GML attributes as dictionaries in the NetworkX graph,
node, and edge attribute structures.

GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
specification.  For writing other data types, and for reading data other
than `str` you need to explicitly supply a `stringizer`/`destringizer`.

For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.

See the module docstring :mod:`networkx.readwrite.gml` for more details.
c                 óÐ   • [        U [        5      (       a   U R                  S5        [        U [
        5      (       d  [        U 5      n U $ ! [         a  n[	        S5      UeS nAff = f)NrA   rB   )r   ÚbytesrD   rE   r	   r   )rG   r9   s     r   Údecode_lineÚparse_gml.<locals>.decode_lineù   s`   € Ü�dœE×"Ñ"ðKØ—‘˜GÔ$ô ˜$¤×$Ñ$Ü�t“9ˆDØˆøô	 &ó KÜ#Ð$@ÓAÀsÐJûðKús   —A
 Á

A%ÁA Á A%c              3   ó  >#   • [        U [        5      (       a#  T" U 5      n U R                  5       n U  S h  v•N   g U  HD  nT" U5      nU(       a  US   S:X  a  US S nUR                  S5      S:w  a  [	        S5      eUv •  MF     g  NP7f)Nr(   rC   zinput line contains newline)r   r   Ú
splitlinesÚfindr	   )rF   rG   rS   s     €r   rH   Úparse_gml.<locals>.filter_lines  s‡   øé € Ü�eœS×!Ñ!Ù Ó&ˆEØ×$Ñ$Ó&ˆEØ×Ñã�Ù" 4Ó(�Þ˜D ™H¨Ó,Ø  ˜9�DØ—9‘9˜T“? bÓ(Ü'Ð(EÓFÐFØ”
ò ñ ùs   ƒ3B	¶B·AB	rJ   )rF   rM   rN   rH   rO   rS   s        @r   r   r   Ç   s&   ø€ òdõô 	™ UÓ+¨UÓA€AØ€Hr   c                   ó4   • \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rg)ÚPatterni  z?encodes the index of each token-matching pattern in `tokenize`.r   r#   r%   r'   é   é   é   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚKEYSÚREALSÚINTSÚSTRINGSÚ
DICT_STARTÚDICT_ENDÚCOMMENT_WHITESPACEÚ__static_attributes__r^   r   r   rZ   rZ     s)   † ÙIà€DØ€EØ€DØ€GØ€JØ€HØÓr   rZ   c                   ó>   • \ rS rSr% \\S'   \\S'   \\S'   \\S'   Srg)ÚTokeni!  ÚcategoryÚvaluerG   Úpositionr^   N)	r_   r`   ra   rb   rZ   Ú__annotations__r   r*   rk   r^   r   r   rm   rm   !  s   ‡ ØÓØƒJØ
ƒIØ†Mr   rm   Ú_networkx_list_startc           
      óÊ  ^ ^^^^^^ • U 4S jnS m UU 4S jmUUUU 4S jmUU4S jmUUU 4S jnU" 5       mU" 5       nUR                  SS5      nUR                  S	S5      nU(       d2  U(       a  [        R                  " 5       O[        R                  " 5       nO1U(       a  [        R                  " 5       O[        R
                  " 5       nUR                  5        V	V
s0 s H  u  pšU	S
;  d  M  Xš_M     nn	n
UR                  R                  U5        S nUR                  S/ 5      n0 n[        5       n[        [        U[        5      (       a  UOU/5       Hz  u  nnU" USSU5      nUU;   a  [        SU< S35      eUb=  US:w  a7  U" USUU5      nUU;   a  [        SU< S35      eUR                  U5        UUU'   UR                   " U40 UD6  M|     UR                  S/ 5      n[        [        U[        5      (       a  UOU/5       GH/  u  nnU" USSU5      nU" USSU5      nUU;  a  [        SU SU< 35      eUU;  a  [        SU SU< 35      eU(       d]  UR#                  UU5      (       d  UR$                  " UU40 UD6  M�  U(       a  SOSnSU SU< U U< S3n[        R                  " U5      eUR                  SS5      nUbT  UR#                  UUU5      (       a<  U(       a  SOSnSU SU< U U< SU< S3	nSn[        R                  " US -   U-   5      eUR$                  " UUU40 UD6  GM2     Ub  US:w  a  [        R&                  " XŽ5      nU$ s  sn
n	f )!zParse GML `lines` into a graph.c            	   3   óä  >#   • / SQn [         R                  " SR                  S U  5       5      5      nSn/ nT GH�  nSnU(       aC  UR                  UR	                  5       5        US   S:X  a  SR                  U5      n/ nObUS-  nMP  UR                  S5      S:X  aF  UR	                  5       S   S:w  a/  UR	                  5       S   S:w  a  UR                  5       /nUS-  nM«  [        U5      nXV:  aÝ  UR                  XE5      nUc  S	XES   S
US-    SUS-    S3n[        U5      e[        [        U 5      5       H‹  n	UR                  U	S-   5      n
U
c  M  U	S:X  a  U
R                  5       nO&U	S:X  a  [        U
5      nOU	S:X  a  [        U
5      nOU
nU	S:w  a  [        [        U	5      X²S-   US-   5      v •  U[        U
5      -  n  O   XV:  a  MÝ  US-  nGM      [        S S US-   S5      v •  g 7f)N)z[A-Za-z][0-9A-Za-z_]*\bz>[+-]?(?:[0-9]*\.[0-9]+|[0-9]+\.[0-9]*|INF)(?:[Ee][+-]?[0-9]+)?z[+-]?[0-9]+z".*?"z\[z\]z#.*$|\s+Ú|c              3   ó.   #   • U  H  nS U S3v •  M     g7f)Ú(Ú)Nr^   )Ú.0Úpatterns     r   Ú	<genexpr>Ú4parse_gml_lines.<locals>.tokenize.<locals>.<genexpr>9  s   é € Ð$LÂ8¸ q¨¨	°¥^Â8ùs   ‚r   r(   Ú"Ú r#   zcannot tokenize ú at (ú, rx   r%   r]   )r   ÚcompileÚjoinÚappendÚstripÚcountÚrstripÚlenÚmatchr	   Úranger   Úfloatr*   rm   rZ   )ÚpatternsÚtokensÚlinenoÚ
multilinesrG   ÚposÚlengthrˆ   r   Úir   ro   rF   s               €r   ÚtokenizeÚ!parse_gml_lines.<locals>.tokenize.  sí  øé € ò	
ˆô —’˜CŸH™HÑ$LÁ8Ó$LÓLÓMˆØˆØˆ
ÜˆDØˆCö
 Ø×!Ñ! $§*¡*£,Ô/Ø˜‘8˜s“?ð Ÿ8™8 JÓ/�DØ!#‘Jà˜a‘K�FÙà—:‘:˜c“? aÓ'Ø—z‘z“| A‘¨#Ó-°$·*±*³,¸rÑ2BÀcÓ2Ið '+§k¡k£m _˜
Ø !™˜Ù ä˜“YˆFà“,ØŸ™ TÓ/�Ø‘=Ø*¨4°¨:¨,°e¸FÀQ¹J¸<ÀrÈ#ÐPQÉ'ÈÐRSÐT�AÜ'¨Ó*Ð*Üœs 8›}Ö-�AØ!ŸK™K¨¨A©Ó.�EØÓ(Ø ›6Ø$)§L¡L£N™EØ !›VÜ$)¨%£L™EØ !›VÜ$'¨£J™Eà$)˜EØ ›6Ü"'¬°«
°EÀA¹:ÀsÈQÁwÓ"OÒOØœs 5›zÑ)˜Ùñ .ð •,ð( �a‰K‹Fñ_ ô` �D˜$ ¨¡
¨AÓ.Ó.ùs   ƒEG0ÅA8G0ÇG0c                 ó\   • U u  p#pEUb  [        U5      OSn[        SU SU SU SU S3	5      e)NÚEOFz	expected z, found r   r€   rx   )Úreprr	   )Ú
curr_tokenÚexpectedrn   ro   r�   r�   s         r   Ú
unexpectedÚ#parse_gml_lines.<locals>.unexpectedn  sD   € Ø'1Ñ$ˆ˜Ø$Ñ0”�U”°eˆÜ˜i¨ z°¸%¸ÀÀfÀXÈRÐPSÈuÐTUÐVÓWÐWr   c                 óL   >• U R                   U:X  a  [        T5      $ T" X5        g ©N)rn   Únext)r—   rn   r˜   rŒ   r™   s      €€r   ÚconsumeÚ parse_gml_lines.<locals>.consumes  s#   ø€ Ø×Ñ (Ó*Ü˜“<ÐÙ�:Õ(r   c                 óT  >• [        [        5      nU R                  [        R                  :X  Ga‰  U R
                  n[        T	5      n U R                  nU[        R                  :X  d  U[        R                  :X  a  U R
                  n[        T	5      n OòU[        R                  :X  aD  [        U R
                  SS 5      nT(       a	   T" U5      nUS:X  a  SnUS:X  a  / n[        T	5      n OšU[        R                  :X  a  T" U 5      u  pO{US;   a;   [        [        U R
                  5      5      nT(       a	   T" U5      n[        T	5      n O:U R
                  S;   a!  [        U R
                  5      n[        T	5      n O	T
" U S	5        X   R!                  W5        U R                  [        R                  :X  a  GM‰  S
 nUR#                  5        VVs0 s H  u  p$X&" U5      _M     nnnX4$ ! [         a     GN'f = f! [         a     NÇf = f! [         a    SnT
" X5         N›f = fs  snnf )Nr#   r(   ú()r^   z[])ÚidrM   ÚsourceÚtargetzQan int, float, string, '[' or string convertible ASCII value for node id or label>   ÚINFÚNANzan int, float, string or '['c                 ó€   • [        U [        5      (       d  U $ [        U 5      S:X  a  U S   $ U S   [        :X  a  U SS  $ U $ )Nr#   r   )r   Úlistr‡   ÚLIST_START_VALUE)ro   s    r   Úclean_dict_valueÚ;parse_gml_lines.<locals>.parse_kv.<locals>.clean_dict_value¯  sF   € Ü˜e¤T×*Ñ*Ø�Ü�5‹z˜Q‹Ø˜Q‘x�Ø�Q‰xÔ+Ó+Ø˜Q˜R�yÐ ØˆLr   )r   r¨   rn   rZ   rd   ro   r�   re   rf   rg   r3   r/   rh   r   Ú	ExceptionrŠ   rƒ   Úitems)r—   ÚdctÚkeyrn   ro   Úmsgrª   rN   Ú
parse_dictrŒ   r™   s          €€€€r   Úparse_kvÚ!parse_gml_lines.<locals>.parse_kvx  s  ø€ Üœ$ÓˆØ×!Ñ!¤W§\¡\Ô1Ø×"Ñ"ˆCÜ˜f›ˆJØ!×*Ñ*ˆHØœ7Ÿ=™=Ó(¨H¼¿¹Ó,DØ"×(Ñ(�Ü! &›\‘
ØœWŸ_™_Ó,Ü  ×!1Ñ!1°!°BÐ!7Ó8�ÞðÙ ,¨UÓ 3˜ð ˜D“=Ø�EØ˜D“=Ø�EÜ! &›\‘
ØœW×/Ñ/Ó/Ù$.¨zÓ$:Ñ!�
˜Eð Ð=Ó=ð4ä (¬¨Z×-=Ñ-=Ó)>Ó ?˜Þ'ð%Ù(4°UÓ(; ô &*¨&£\™
ð  ×%Ñ%¨Ó7Ü! *×"2Ñ"2Ó3�EÜ!% f£‘Já˜zÐ+IÔJØ‰H�O‰O˜EÔ"ðg ×!Ñ!¤W§\¡\Ö1òj	ð ?B¿i¹i¼kÔJºk±
°ˆsÐ$ UÓ+Ò+¹kˆÑJØˆÐøôg &ó Úðûô& $.ó %Ù $ð%ûô %ó 4ðNð ñ # :Ö3ð4üó8 KsN   ÃG) Ä%H
 Ä7G: Ä?H
 ÇH$Ç)
G7Ç6G7Ç:
HÈH
 ÈHÈH
 È
H!È H!c                 ó~   >• T" U [         R                  S5      n T" U 5      u  pT" U [         R                  S5      n X4$ )Nz'['z']')rZ   rh   ri   )r—   r®   rž   r²   s     €€r   r±   Ú#parse_gml_lines.<locals>.parse_dict»  s?   ø€ á˜Z¬×);Ñ);¸UÓCˆ
á" :Ó.‰ˆ
á˜Z¬×)9Ñ)9¸5ÓAˆ
ØˆÐr   c                  óÆ   >• T" [        T5      5      u  pU R                  b	  T" U S5        SU;  a  [        S5      eUS   n[        U[        5      (       a  [        S5      eU$ )Nr•   Úgraphzinput contains no graphz"input contains more than one graph)r�   rn   r	   r   r¨   )r—   r®   r·   r²   rŒ   r™   s      €€€r   Úparse_graphÚ$parse_gml_lines.<locals>.parse_graphÄ  sd   ø€ Ù"¤4¨£<Ó0‰ˆ
Ø×ÑÑ*Ù�z 5Ô)Ø˜#ÓÜÐ 9Ó:Ð:Ø�G‘ˆÜ�eœT×"Ñ"ÜÐ DÓEÐEØˆr   ÚdirectedFÚ
multigraph)ÚnodeÚedgec           	      óv   •  U R                  U5      $ ! [         a  n[        U SU SU< S35      UeS nAff = f)Nz #z has no z
 attribute)Úpopr-   r	   )r®   rn   Úattrr‘   r9   s        r   Úpop_attrÚ!parse_gml_lines.<locals>.pop_attrÛ  sI   € ð	WØ—7‘7˜4“=Ð øÜó 	WÜ 8 *¨B¨q¨c°¸$¹ÀÐ LÓMÐSVÐVûð	Wús   ‚ “
8�3³8r¼   r¢   znode id z is duplicatedNznode label r½   r£   r¤   zedge #z has undefined source z has undefined target z->z--z (z) is duplicatedr¯   r€   rx   z6Hint: If multigraph add "multigraph 1" to file header.z is duplicated
)r¿   ÚnxÚDiGraphÚGraphÚMultiDiGraphÚ
MultiGraphr­   r·   ÚupdateÚgetÚsetÚ	enumerater   r¨   r	   ÚaddÚadd_nodeÚhas_edgeÚadd_edgeÚrelabel_nodes)!rF   rM   rN   r’   r¸   r·   rº   r»   rO   ÚkÚvÚ
graph_attrrÁ   ÚnodesÚmappingÚnode_labelsr‘   r¼   r¢   Ú
node_labelÚedgesr½   r£   r¤   Úarrowr°   r¯   Úmsg2rž   r±   r²   rŒ   r™   s!   ` `                         @@@@@r   rK   rK   +  s7  þ€ õ>/ò@Xö
)÷
Að AöF÷	ñ ‹Z€FÙ‹M€Eà�y‰y˜ UÓ+€HØ—‘˜<¨Ó/€JÞÞ$ŒB�JŠJŒL¬"¯(ª(«*‰æ!)ŒB�OŠOÔ¬r¯}ª}«ˆØ#(§;¡;¤=ÔN¢=™4˜1°AÐ=MÑ4M“$�!’$¡=€JÑNØ‡G�G‡N�N�:ÔòWð �I‰I�f˜bÓ!€EØ€GÜ“%€KÜ¤j°¼×&=Ñ&=™UÀEÀ7ÖK‰ˆˆ4Ù�d˜F D¨!Ó,ˆØ�‹7Ü (¨2©&°Ð ?Ó@Ð@ØÑ ¨$£Ù! $¨°°qÓ9ˆJØ˜[Ó(Ü# k°*±¸~Ð$NÓOÐOØ�O‰O˜JÔ'Ø$ˆG�B‰KØ	�
Š
�2Ñ˜Ôñ Lð �I‰I�f˜bÓ!€EÜ¤j°¼×&=Ñ&=™UÀEÀ7×K‰ˆˆ4Ù˜$ ¨°!Ó4ˆÙ˜$ ¨°!Ó4ˆØ˜‹?Ü &¨¨Ð+AÀ&ÁÐ LÓMÐMØ˜‹?Ü &¨¨Ð+AÀ&ÁÐ LÓMÐMÞØ—:‘:˜f f×-Ñ-Ø—
’
˜6 6Ñ2¨TÔ2æ (™¨d�Ø˜q˜c  F¡:¨e¨W°V±J¸oÐN�Ü×&Ò& sÓ+Ð+à—(‘(˜5 $Ó'ˆCØ‰ 1§:¡:¨f°f¸c×#BÑ#BÞ (™¨d�Ø˜q˜c  F¡:¨e¨W°V±J¸bÀÁÀqÐI�ØO�Ü×&Ò& sÐ-?Ñ'?À$Ñ'FÓGÐGØ�JŠJ�v˜v sÑ3¨dÕ3ñ+ Lð. Ñ˜U d›]Ü×Ò˜QÓ(ˆØ€Hùóe Os   ÃMÃ/Mc                 óX   ^^• UU4S jm[        5       mT" U 5        TR                  5       $ )aò  Convert a `value` to a Python literal in GML representation.

Parameters
----------
value : object
    The `value` to be converted to GML representation.

Returns
-------
rep : string
    A double-quoted Python literal representing value. Unprintable
    characters are replaced by XML character references.

Raises
------
ValueError
    If `value` cannot be converted to GML.

Notes
-----
The original value can be recovered using the
:func:`networkx.readwrite.gml.literal_destringizer` function.
c                 ó˜  >• [        U [        [        -  5      (       d  U c[  U SL a  TR                  [	        S5      5        g U SL a  TR                  [	        S5      5        g TR                  [	        U 5      5        g [        U [        5      (       a8  [        U 5      nUS   S:w  a   U R                  S5        TR                  U5        g [        U [        [        -  [        -  [        -  5      (       a  TR                  [        U 5      5        g [        U [        5      (       aQ  TR                  S5        SnU  H&  nU(       d  TR                  S5        OSnT" U5        M(     TR                  S	5        g [        U [        5      (       a§  [        U 5      S:”  aQ  TR                  S
5        SnU  H&  nU(       d  TR                  S5        OSnT" U5        M(     TR                  S5        g U (       a.  TR                  S
5        T" U S   5        TR                  S5        g TR                  S5        g [        U [        5      (       az  TR                  S5        SnU R                  5        HA  u  p@U(       d  TR                  S5        OSnT" U5        TR                  S5        T" U 5        MC     TR                  S5        g [        U [         5      (       aQ  TR                  S5        SnU  H&  nU(       d  TR                  S5        OSnT" U5        M(     TR                  S5        g U < S3n[#        U5      e! [         a	    SU-   n GN‘f = f)NTr#   Fr   ÚuÚlatin1Ú[Ú,Ú]rw   rx   z,)r¡   Ú{Ú:Ú}z* cannot be converted into a Python literal)r   r*   ÚboolÚwriter   r–   ÚencodeÚUnicodeEncodeErrorrŠ   ÚcomplexrR   r¨   Útupler‡   Údictr­   rÊ   r/   )ro   r   ÚfirstÚitemr¯   r°   ÚbufÚ	stringizes         €€r   rï   Ú%literal_stringizer.<locals>.stringize&  s€  ø€ Ü�eœS¤4™Z×(Ñ(¨E©MØ˜Š}Ø—	‘	œ#˜a›&Õ!Ø˜%’Ø—	‘	œ#˜a›&Õ!à—	‘	œ#˜e›*Õ%Ü˜œs×#Ñ#Ü˜“;ˆDØ�A‰w˜#‹~ð&Ø—L‘L Ô*ð �I‰I�d�OÜ˜œu¤w™´Ñ4´uÑ<×=Ñ=Ø�I‰I”d˜5“kÕ"Ü˜œt×$Ñ$Ø�I‰I�cŒNØˆEÛ�ÞØ—I‘I˜c•Nà!�EÙ˜$–ñ ð �I‰I�c�NÜ˜œu×%Ñ%Ü�5‹z˜A‹~Ø—	‘	˜#”Ø�Û!�DÞ ØŸ	™	 #�à %˜Ù˜d–Oñ "ð —	‘	˜#•ÞØ—	‘	˜#”Ù˜% ™(Ô#Ø—	‘	˜$•à—	‘	˜$•Ü˜œt×$Ñ$Ø�I‰I�cŒNØˆEØ#Ÿk™kžm‘
�ÞØ—I‘I˜c•Nà!�EÙ˜#”Ø—	‘	˜#”Ù˜%Ö ñ ,ð �I‰I�c�NÜ˜œs×#Ñ#Ø�I‰I�cŒNØˆEÛ�ÞØ—I‘I˜c•Nà!�EÙ˜$–ñ ð �I‰I�c�Nà‘IÐGÐHˆCÜ˜S“/Ð!øôq *ó &Ø ™:“Dð&ús   Â&L6 Ì6M	ÍM	)r   Úgetvalue)ro   rî   rï   s    @@r   Úliteral_stringizerrò     s'   ù€ ö2E"ôN ‹*€CÙˆeÔØ�<‰<‹>Ðr   c           
   #   ó  ^^^#   • [         R                  " S5      mSUUU4S jjmU R                  5       nSv •  U R                  5       (       a  Sv •  U(       a  Sv •  1 SknU R                  R                  5        H  u  pET" XEUS5       Sh  v•N   M     [        [        U [        [        U 5      5      5      5      nS	S
1nU R                  R                  5        H]  u  pxSv •  S[        Xg   5      -   v •  T" S
USS5       Sh  v•N   UR                  5        H  u  pET" XEUS5       Sh  v•N   M     Sv •  M_     SS1nSS0n	U(       a  UR                  S5        SU	S'   U R                  " S0 U	D6 H€  n
Sv •  S[        XjS      5      -   v •  S[        XjS      5      -   v •  U(       a  T" SU
S   SS5       Sh  v•N   U
S   R                  5        H  u  pET" XEUS5       Sh  v•N   M     Sv •  M‚     Sv •  g GNo Nú NÕ NF N7f)a   Generate a single entry of the graph `G` in GML format.

Parameters
----------
G : NetworkX graph
    The graph to be converted to GML.

stringizer : callable, optional
    A `stringizer` which converts non-int/non-float/non-dict values into
    strings. If it cannot convert a value into a string, it should raise a
    `ValueError` to indicate that. Default value: None.

Returns
-------
lines: generator of strings
    Lines of GML data. Newlines are not appended.

Raises
------
NetworkXError
    If `stringizer` cannot convert a value into a string, or the value to
    convert is not a string while `stringizer` is None.

See Also
--------
literal_stringizer

Notes
-----
Graph attributes named 'directed', 'multigraph', 'node' or
'edge', node attributes named 'id' or 'label', edge attributes
named 'source' or 'target' (or 'key' if `G` is a multigraph)
are ignored because these attribute names are used to encode the graph
structure.

GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
specification.  For writing other data types, and for reading data other
than `str` you need to explicitly supply a `stringizer`/`destringizer`.

For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.

See the module docstring :mod:`networkx.readwrite.gml` for more details.

Examples
--------
>>> G = nx.Graph()
>>> G.add_node("1")
>>> print("\n".join(nx.generate_gml(G)))
graph [
  node [
    id 0
    label "1"
  ]
]
>>> G = nx.MultiGraph([("a", "b"), ("a", "b")])
>>> print("\n".join(nx.generate_gml(G)))
graph [
  multigraph 1
  node [
    id 0
    label "a"
  ]
  node [
    id 1
    label "b"
  ]
  edge [
    source 0
    target 1
    key 0
  ]
  edge [
    source 0
    target 1
    key 1
  ]
]
z^[A-Za-z][0-9A-Za-z_]*$c              3   ó¨  >#   • [        U [        5      (       d  [        U < S35      eTR                  U 5      (       d  [        U < S35      e[        U [        5      (       d  [        U 5      n X;  Ga·  [        U[        [
        -  5      (       ax  U S:X  a  X0-   S-   [        U5      -   S-   v •  g USL a
  X0-   S-   v •  g USL a
  X0-   S	-   v •  g US
:  d  US:¼  a  X0-   S-   [        U5      -   S-   v •  g X0-   S-   [        U5      -   v •  g [        U[        5      (       a£  [        U5      R                  5       nU[        [        S5      5      R                  5       :X  a  SU-   nO;UR                  S5      nUS:w  a$  UR                  SSU5      S:X  a  US U S-   XVS  -   nU S:X  a  X0-   S-   U-   S-   v •  g X0-   S-   U-   v •  g [        U[        5      (       aA  X0-   S-   v •  US-   nUR                  5        H  u  pT
" XSU5       S h  v•N   M     US-   v •  g [        U[        5      (       a*  U S:X  a$  X0-   SSR                  S U 5       5       S3-   v •  g [        U[        [        -  5      (       am  U S:w  ag  U(       d`  [!        U5      S:X  a  X0-   S-   SU< S3-   v •  [!        U5      S:X  a  X0-   S-   S["         S3-   v •  U H  nT
" XSUS5       S h  v•N   M     g T(       a	   T" U5      n[        U[        5      (       d  [        U< S35      eX0-   S-   ['        U5      -   S-   v •  g g  GN' NZ! [$         a  n	[        U< S35      U	eS n	A	ff = f7f)Nr5   z is not a valid keyrM   z "r}   Tz 1Fz 0i   €l        r~   ÚinfÚ+ÚEr(   Ú.r   z [ú  r^   rá   z "(rà   c              3   ó8   #   • U  H  n[        U5      v •  M     g 7frœ   )r–   )ry   rÒ   s     r   r{   Ú2generate_gml.<locals>.stringize.<locals>.<genexpr>ô  s   é € Ð3KÂUÀ´D¸·G°GÂUùs   ‚z)"r#   z" cannot be converted into a string)r   r   r	   rˆ   r*   rå   rŠ   r–   ÚupperÚrfindrW   rë   r­   rê   r‚   r¨   r‡   r©   r/   r    )r¯   ro   Úignored_keysÚindentÚin_listr   ÚeposÚnext_indentÚvalr9   rï   Ú
stringizerÚ
valid_keyss             €€€r   rï   Úgenerate_gml.<locals>.stringizeÇ  sU  øé € Ü˜#œs×#Ñ#Ü 3¡'Ð)9Ð :Ó;Ð;Ø×Ñ ×$Ñ$Ü 3¡'Ð)<Ð =Ó>Ð>Ü˜#œs×#Ñ#Ü�c“(ˆCØÔ"Ü˜%¤¤t¡×,Ñ,Ø˜'“>Ø ™,¨Ñ-´°E³
Ñ:¸SÑ@Ó@Ø˜d’]à ™,¨Ñ-Ó-Ø˜e’^Ø ™,¨Ñ-Ó-à˜XÓ%¨°%«Ø ™,¨Ñ-´°E³
Ñ:¸SÑ@Ó@à ™,¨Ñ,¬s°5«zÑ9Ó9Ü˜E¤5×)Ñ)Ü˜E“{×(Ñ(Ó*�ð œ4¤ e£Ó-×3Ñ3Ó5Ó5Ø ™:‘Dð
  Ÿ:™: c›?�DØ˜r“z d§i¡i°°Q¸Ó&=ÀÓ&CØ# E T˜{¨SÑ0°4¸°;Ñ>˜Ø˜'“>Ø ™,¨Ñ-°Ñ4°sÑ:Ó:à ™,¨Ñ,¨tÑ3Ó3Ü˜E¤4×(Ñ(Ø‘l TÑ)Ò)Ø$ t™m�Ø"'§+¡+¦-‘J�CÙ(¨°R¸ÓE×EÒEñ #0à˜s‘lÓ"Ü˜E¤5×)Ñ)¨c°W«nØ‘l s¨3¯8©8Ñ3KÁUÓ3KÓ+KÐ*LÈBÐ%OÑOÓOÜ˜E¤4¬%¡<×0Ñ0°S¸G³^ÎGÜ�u“: “?Ø ™,¨Ñ,°°5±)¸1¨~Ñ=Ò=Ü�u“: “?Ø ™,¨Ñ,°Ô3CÐ2DÀAÐ/FÑFÒFÛ �CÙ(¨°2°v¸tÓD×DÒDò !ö ð#Ù *¨5Ó 1˜ô
 " %¬×-Ñ-Ü'¨5©)Ð3CÐ(DÓEÐEØ‘l TÑ)¬F°5«MÑ9¸CÑ?Ó?ðq #òF Fñ Eøô
 &ó #Ü+Ø$™iÐ'IÐJóà"ð#ûð#üsI   ƒHMÈL+ÈCMËL.ËMË%L0 Ë-?MÌ.MÌ0
MÌ:M
Í
MÍMzgraph [z  directed 1z  multigraph 1>   r½   r¼   rº   r»   rù   Nr¢   rM   z  node [z    id r^   z    z  ]r£   r¤   ÚdataTr¯   Úkeysz  edge [z    source r   z    target r#   r%   r(   rá   )F)r   r�   Úis_multigraphÚis_directedr·   r­   rë   Úzipr‰   r‡   rÔ   r   rÌ   rØ   )rO   r  r»   rþ   rÀ   ro   Únode_idr¼   ÚattrsÚkwargsÚerï   r  s    `         @@r   r   r   r  së  úé € ôf —’Ð5Ó6€J÷?@ñ ?@ðB —‘Ó"€JØ
‚Oð 	‡}�}‡�ØÒÞØÒÚ=€LØ—w‘w—}‘}–‰ˆÙ˜T¨,¸Ó=×=Ò=ñ 'ô ”3�qœ%¤ A£›-Ó(Ó)€GØ˜'�?€LØ—w‘w—}‘}–‰ˆØÒØœ#˜g™mÓ,Ñ,Ò,Ù˜W d¨B°Ó7×7Ð7Ø Ÿ;™;ž=‰KˆDÙ  ¨l¸FÓC×CÒCñ )àŒñ 'ð ˜hÐ'€LØ�dˆ^€FÞØ×Ñ˜ÔØˆˆv‰Ø�WŠWÑ�vÔˆØÒØœc '¨A©$¡-Ó0Ñ0Ò0Øœc '¨A©$¡-Ó0Ñ0Ò0ÞÙ  ¨¨!©¨b°&Ó9×9Ð9Ø˜R™5Ÿ;™;ž=‰KˆDÙ  ¨l¸FÓC×CÒCñ )àŒñ ð ƒIò9 	>ñ 	8áCñ :áCùs\   …B	HÂG=ÂA6HÄH Ä&HÄ,HÄ-BHÆ=HÆ>)HÇ'HÇ(HÈ HÈHÈHÈHr#   Úwbc                 ón   • [        X5       H&  nUR                  US-   R                  S5      5        M(     g)aâ  Write a graph `G` in GML format to the file or file handle `path`.

Parameters
----------
G : NetworkX graph
    The graph to be converted to GML.

path : string or file
    Filename or file handle to write to.
    Filenames ending in .gz or .bz2 will be compressed.

stringizer : callable, optional
    A `stringizer` which converts non-int/non-float/non-dict values into
    strings. If it cannot convert a value into a string, it should raise a
    `ValueError` to indicate that. Default value: None.

Raises
------
NetworkXError
    If `stringizer` cannot convert a value into a string, or the value to
    convert is not a string while `stringizer` is None.

See Also
--------
read_gml, generate_gml
literal_stringizer

Notes
-----
Graph attributes named 'directed', 'multigraph', 'node' or
'edge', node attributes named 'id' or 'label', edge attributes
named 'source' or 'target' (or 'key' if `G` is a multigraph)
are ignored because these attribute names are used to encode the graph
structure.

GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
specification.  For writing other data types, and for reading data other
than `str` you need to explicitly supply a `stringizer`/`destringizer`.

Note that while we allow non-standard GML to be read from a file, we make
sure to write GML format. In particular, underscores are not allowed in
attribute names.
For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.

See the module docstring :mod:`networkx.readwrite.gml` for more details.

Examples
--------
>>> G = nx.path_graph(5)
>>> nx.write_gml(G, "test_path5.gml")

Filenames ending in .gz or .bz2 will be compressed.

>>> nx.write_gml(G, "test_path5.gml.gz")
rC   rA   N)r   ræ   rç   )rO   rL   r  rG   s       r   r   r   1  s/   € ôz ˜QÖ+ˆØ�
‰
�D˜4‘K×'Ñ'¨Ó0Ö1ò ,r   )rM   Nrœ   )$rc   Úhtml.entitiesÚentitiesr+   r   Úastr   Úcollectionsr   Úenumr   Úior   Útypingr   r   ÚnetworkxrÃ   Únetworkx.exceptionr	   Únetworkx.utilsr
   Ú__all__r    r3   r:   Ú_dispatchabler   r   rZ   rm   r©   rK   rò   r   r   r^   r   r   Ú<module>r     sæ   ðñõ< 'Û 	Ý Ý #Ý Ý ß "ã Ý ,Ý $â
@€ò8òOò25ñ8 ˆ1�4ÑØ×Ò˜¨TÑ2óPó 3ó ðPðf ×Ò˜¨TÑ2óJó 3ðJôZ	ˆdô 	ôˆJô ð *Ð ò_òDbôJ|ñ~ ˆ1�4Ñó=2ó ñ=2r   