+
    �°³j)  ã                   ó  € R t ^ RIt^ RIHtHt ^ RIHtHt . ROt	R t
]P                  ! RRR7      R 4       tRR lt]! ^ R	R
7      ]P                  ! RRR7      R 4       4       t]! R4      ]! ^RR
7      RR l4       4       tR# )aP  Functions for reading and writing graphs in the *sparse6* format.

The *sparse6* file format is a space-efficient format for large sparse
graphs. For small graphs or large dense graphs, use the *graph6* file
format.

For more information, see the `sparse6`_ homepage.

.. _sparse6: https://users.cecs.anu.edu.au/~bdm/data/formats.html

N)Ú	data_to_nÚ	n_to_data)Únot_implemented_forÚ	open_filec              #  ó2  a"  € \        V 4      pVR8¼  d   \        R4      hV'       d   Rx € Rx € \        V4       F*  p\        P	                  \        V^?,           4      4      x € K,  	  ^o^S,          V8  d   S^,          oK  V3R lp\        R V P                  4        4       4      p. p^ pV FÇ  w  ršW˜8X  d+   VP                  ^ 4       VP                  V! V
4      4       K5  W˜^,           8X  d4   V^,          pVP                  ^4       VP                  V! V
4      4       Ku  T	pVP                  ^4       VP                  V! V	4      4       VP                  ^ 4       VP                  V! V
4      4       KÉ  	  S^8  dp   V^S,          8X  db   \        V4      ) ^,          S8¼  dJ   Wƒ^,
          8  d=   VP                  ^ 4       VP                  ^.\        V4      ) ^,          ,          4       M*VP                  ^.\        V4      ) ^,          ,          4       \        ^ \        V4      ^4       Uu. uF   pW{^ ,           ,          ^,          W{^,           ,          ^,          ,           W{^,           ,          ^,          ,           W{^,           ,          ^,          ,           W{^,           ,          ^,          ,           W{^,           ,          ^ ,          ,           NK¢  	  ppV F*  p\        P	                  \        V^?,           4      4      x € K,  	  Rx € R# u upi 5i)	aí  Yield bytes in the sparse6 encoding of a graph.

`G` is an undirected simple graph. `nodes` is the list of nodes for
which the node-induced subgraph will be encoded; if `nodes` is the
list of all nodes in the graph, the entire graph will be
encoded. `header` is a Boolean that specifies whether to generate
the header ``b'>>sparse6<<'`` before the remaining data.

This function generates `bytes` objects in the following order:

1. the header (if requested),
2. the encoding of the number of nodes,
3. each character, one-at-a-time, in the encoding of the requested
   node-induced subgraph,
4. a newline character.

This function raises :exc:`ValueError` if the graph is too large for
the graph6 format (that is, greater than ``2 ** 36`` nodes).

z?sparse6 is only defined if number of nodes is less than 2 ** 36ó   >>sparse6<<ó   :c                óŽ   <€ \        S4       Uu. uF*  q^S^,
          V,
          ,          ,          '       d   ^M^ NK,  	  up# u upi )zBig endian k-bit encoding of x)Úrange)ÚxÚiÚks   & €Ú[/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/readwrite/sparse6.pyÚencÚ$_generate_sparse6_bytes.<locals>.enc:   s9   ø€ ä<AÀ!¼HÓE¹H°q˜!  A¥¨¥	Õ*×*Ô*‘°Ò2¹HÑEÐEùÒEs   �0Ac              3   óR   "  € T F  w  r\        W4      \        W4      3x € K  	  R # 5i)N)ÚmaxÚmin)Ú.0ÚuÚvs   &  r   Ú	<genexpr>Ú*_generate_sparse6_bytes.<locals>.<genexpr>>   s   é € Ð@±i©d¨a”C˜“Iœs 1›yÕ)³iùs   ‚%'ó   
Nl       @ )ÚlenÚ
ValueErrorr   ÚstrÚencodeÚchrÚsortedÚedgesÚappendÚextendr
   )ÚGÚnodesÚheaderÚnÚdr   r    ÚbitsÚcurvr   r   r   Údatar   s   &&&          @r   Ú_generate_sparse6_bytesr+      s  øé € ô* 	ˆA‹€AØˆE„zÜØMó
ð 	
÷ ØÒØ
‚JÜ�qŽ\ˆÜ�j‰jœ˜Q �V›Ó%Ô%ñ ð 	
€AØ
ˆq�&�1Œ*Ø	ˆQ�ŠõFô Ñ@°a·g±g´iÓ@Ó@€EØ€DØ€DÛ‰ˆØŒ9Ø�K‰K˜ŒNØ�K‰K™˜A›ÖØ˜•(Œ]Ø�A�IˆDØ�K‰K˜ŒNØ�K‰K™˜A›ÖàˆDØ�K‰K˜ŒNØ�K‰K™˜A›ÔØ�K‰K˜ŒNØ�K‰K™˜A›Öñ ð 	ˆ1„u��q˜A•v”¤c¨$£i Z°1Õ$4¸Ô#:¸tÈ1Åu¼~ð
 	�‰�AŒØ�‰�Q�CœS ›Y˜J¨!Õ+Õ,Õ-à�‰�Q�CœS ›Y˜J¨!Õ+Õ,Ô-ô �qœ#˜d›) QÔ'óñ (ˆAð 
�!�e�˜Õ	Ø�A•�;˜!Õõ	à�A•�;˜!Õõ	ð �A•�;˜!Õõ	ð �A•�;˜!Õõ		ð
 �A•�;˜!Õ÷	ð 	ñ (ð 	ð ó ˆÜ�j‰jœ˜Q �V›Ó%Ô%ñ à
„Kùòùs   ƒ%L©HLÈ4B&LË=LT)ÚgraphsÚreturns_graphc                ó:  a
a€ V P                  R4      '       d
   V R,          p V P                  R4      '       g   \        P                  ! R4      hV R,           Uu. uF  q^?,
          NK  	  pp\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \	        R	4      h\        V4      w  po
^o^S,          V8  d   S^,          oK  V
V3R
 lp^ p\        P                  ! 4       pVP                  \        V4      4       RpV! 4        FW  w  r‰V^8X  d
   V^,          pW“8¼  g   WS8¼  d    M8W•8”  d   T	pK-  VP                  W•4      '       d   RpVP                  W•4       KY  	  V'       g   \        P                  ! V4      pV# u upi )aö  Read an undirected graph in sparse6 format from string.

Parameters
----------
string : string
   Data in sparse6 format

Returns
-------
G : Graph

Raises
------
NetworkXError
    If the string is unable to be parsed in sparse6 format

Examples
--------
>>> G = nx.from_sparse6_bytes(b":A_")
>>> sorted(G.edges())
[(0, 1), (0, 1), (0, 1)]

See Also
--------
read_sparse6, write_sparse6

References
----------
.. [1] Sparse6 specification
       <https://users.cecs.anu.edu.au/~bdm/data/formats.html>

r   :é   NNr   z!Expected leading colon in sparse6:é   NNc              3   óD   "  € T F  q^ 8  ;'       g    V^?8„  x € K  	  R# 5i)é    N© )r   Úcs   & r   r   Ú%from_sparse6_bytes.<locals>.<genexpr>�   s   é € Ð
*¡E˜qˆq‰5�?ˆ?�A˜‘FŒ?£Eùs   ‚ ’ TFz.each input character must be in range(63, 127)c               3  óž  <"  € \        S4      p Rp^ p V^8  d    \        V 4      p^pV^,          pW,	          ^,          pV^V,          ^,
          ,          pTpVS8  d*    \        V 4      p^pT^,          T,           pT^,          pK0  WES,
          ,	          pVS,
          pW43x € K–    \         d     R# i ; i  \         d     R# i ; i5i)z6Returns stream of pairs b[i], x[i] for sparse6 format.N)ÚiterÚnextÚStopIteration)Úchunksr'   ÚdLenÚbr   ÚxLenr*   r   s         €€r   Ú	parseDataÚ%from_sparse6_bytes.<locals>.parseData—   sÖ   øé € ä�d“ˆØˆØˆàØ�aŒxðÜ˜V›�Að �Ø�A�IˆDØ•˜a•ˆAà�a˜4•i 1•_Õ%ˆAØˆDØ˜”(ðÜ˜V›�Að �Ø˜!•V˜q•L�Ø˜•	’Ø˜Q•h•ˆAØ˜!•8ˆDØ�$ŒJøô% %ô Úðûô %ô ÚðüsK   ƒCœB) §:CÁ"B; Á-<CÂ)B8Â4CÂ7B8Â8CÂ;C
ÃCÃ	C
Ã
C)Ú
startswithÚnxÚNetworkXErrorÚanyr   r   Ú
MultiGraphÚadd_nodes_fromr
   Úhas_edgeÚadd_edgeÚGraph)Ústringr4   Úcharsr&   r>   r   r#   Ú
multigraphr<   r   r*   r   s   &         @@r   Úfrom_sparse6_bytesrL   h   sR  ù€ ðD ×Ñ˜×(Ò(Ø˜•ˆØ×Ñ˜T×"Ò"Ü×ÒÐBÓCÐCà# BžZÓ(™Z˜��VˆV™Z€EÐ(ß
ƒsÑ
*¡EÓ
*‡s‡s‚sÑ
*¡EÓ
*×*Ò*ÜÐIÓJÐJÜ˜Ó�G€A€tØ	€AØ
ˆq�&�1Œ*Ø	ˆQ�Šöð< 	
€Aä
�Š‹€AØ×Ñ”U˜1“XÔà€JÙ–‰ˆØ�Œ6Ø��FˆAàŒ6�Q”VÙØŒUØŠAà�z‰z˜!×ÒØ!�
Ø�J‰J�qÖñ ÷ Ü�HŠH�Q‹KˆØ€Hùòu )s   ÁFc                ó’   € Ve   V P                  V4      p \        P                  ! V RR7      p RP                  \	        WV4      4      # )a{  Convert an undirected graph to bytes in sparse6 format.

Parameters
----------
G : Graph (undirected)

nodes: list or iterable
   Nodes are labeled 0...n-1 in the order provided.  If None the ordering
   given by ``G.nodes()`` is used.

header: bool
   If True add '>>sparse6<<' bytes to head of data.

Raises
------
NetworkXNotImplemented
    If the graph is directed.

ValueError
    If the graph has at least ``2 ** 36`` nodes; the sparse6 format
    is only defined for graphs of order less than ``2 ** 36``.

Examples
--------
>>> nx.to_sparse6_bytes(nx.path_graph(2))
b'>>sparse6<<:An\n'

See Also
--------
to_sparse6_bytes, read_sparse6, write_sparse6_bytes

Notes
-----
The returned bytes end with a newline character.

The format does not support edge or node labels.

References
----------
.. [1] Graph6 specification
       <https://users.cecs.anu.edu.au/~bdm/data/formats.html>

r   ©Úorderingó    )ÚsubgraphrA   Úconvert_node_labels_to_integersÚjoinr+   )r#   r$   r%   s   &&&r   Úto_sparse6_bytesrT   Ì   sB   € ðX ÒØ�J‰J�uÓˆÜ
×*Ò*¨1°xÔ@€AØ�8‰8Ô+¨A°fÓ=Ó>Ð>rP   Úrb)Úmodec                óÈ   € . pV  F@  pVP                  4       p\        V4      '       g   K&  VP                  \        V4      4       KB  	  \        V4      ^8X  d
   V^ ,          # V# )a¦  Read an undirected graph in sparse6 format from path.

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

Returns
-------
G : Graph/Multigraph or list of Graphs/MultiGraphs
   If the file contains multiple lines then a list of graphs is returned

Raises
------
NetworkXError
    If the string is unable to be parsed in sparse6 format

Examples
--------
You can read a sparse6 file by giving the path to the file::

    >>> import tempfile
    >>> with tempfile.NamedTemporaryFile(delete=False) as f:
    ...     _ = f.write(b">>sparse6<<:An\n")
    ...     _ = f.seek(0)
    ...     G = nx.read_sparse6(f.name)
    >>> list(G.edges())
    [(0, 1)]

You can also read a sparse6 file by giving an open file-like object::

    >>> import tempfile
    >>> with tempfile.NamedTemporaryFile() as f:
    ...     _ = f.write(b">>sparse6<<:An\n")
    ...     _ = f.seek(0)
    ...     G = nx.read_sparse6(f)
    >>> list(G.edges())
    [(0, 1)]

See Also
--------
read_sparse6, from_sparse6_bytes

References
----------
.. [1] Sparse6 specification
       <https://users.cecs.anu.edu.au/~bdm/data/formats.html>

)Ústripr   r!   rL   )ÚpathÚglistÚlines   &  r   Úread_sparse6r\   þ   sX   € ðj €EÛˆØ�z‰z‹|ˆÜ�4�yŠyÙØ�‰Ô'¨Ó-Ö.ñ	 ô
 ˆ5ƒz�Q„Ø�Q�xˆàˆrP   ÚdirectedÚwbc                ó¨   € Ve   V P                  V4      p \        P                  ! V RR7      p \        WV4       F  pVP	                  V4       K  	  R# )a¸  Write graph G to given path in sparse6 format.

Parameters
----------
G : Graph (undirected)

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

nodes: list or iterable
   Nodes are labeled 0...n-1 in the order provided.  If None the ordering
   given by G.nodes() is used.

header: bool
   If True add '>>sparse6<<' string to head of data

Raises
------
NetworkXError
    If the graph is directed

Examples
--------
You can write a sparse6 file by giving the path to the file::

    >>> import tempfile
    >>> with tempfile.NamedTemporaryFile(delete=False) as f:
    ...     nx.write_sparse6(nx.path_graph(2), f.name)
    ...     print(f.read())
    b'>>sparse6<<:An\n'

You can also write a sparse6 file by giving an open file-like object::

    >>> with tempfile.NamedTemporaryFile() as f:
    ...     nx.write_sparse6(nx.path_graph(2), f)
    ...     _ = f.seek(0)
    ...     print(f.read())
    b'>>sparse6<<:An\n'

See Also
--------
read_sparse6, from_sparse6_bytes

Notes
-----
The format does not support edge or node labels.

References
----------
.. [1] Sparse6 specification
       <https://users.cecs.anu.edu.au/~bdm/data/formats.html>

Nr   rN   )rQ   rA   rR   r+   Úwrite)r#   rY   r$   r%   r<   s   &&&& r   Úwrite_sparse6ra   ?  sG   € ðr ÒØ�J‰J�uÓˆÜ
×*Ò*¨1°xÔ@€AÜ$ Q¨vÖ6ˆØ�
‰
�1Žó 7rP   )rL   r\   rT   ra   )NT)Ú__doc__ÚnetworkxrA   Únetworkx.readwrite.graph6r   r   Únetworkx.utilsr   r   Ú__all__r+   Ú_dispatchablerL   rT   r\   ra   r3   rP   r   Ú<module>rh      s¤   ðñ
ó ß :ß 9â
U€òOðd ×Ò˜¨TÔ2ñ`ó 3ð`ôF/?ñd ˆ1�4ÔØ×Ò˜¨TÔ2ñ<ó 3ó ð<ñ~ �ZÓ Ù
ˆ1�4Ôó;ó ó !ò;rP   