+
    )i(                        R t ^ RIt^ RIH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)NetworkXError)	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  rW8X  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   & X/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/readwrite/sparse6.pyenc$_generate_sparse6_bytes.<locals>.enc;   s9    <A!HEHq!A	***2H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     @idaCIs1y)is   %'   
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EzM
 	
 
Jq\jjQV%%  	
A
q&1*	QF @aggi@@EDD9KKNKKA(]AIDKKNKKADKKNKKAKKNKKA  	1uqAvc$iZ1$4#:t1u~
 	AQCSYJ!+,-QCSYJ!+,- q#d)Q' (A 
!e	A;!	A;!	 A;!	 A;!		
 A;!	 	 ( 	  jj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   \        R4      hV R,           Uu. uF  q^?,
          NK  	  pp\        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  rV^8X  d
   V^,          pW8  g   WS8  d    M8W8  d   T	pK-  VP                  W4      '       d   RpVP                  W4       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    <"   \        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axVA AIDaAa4i1_%AD(VA !VqL	QhA!8D$J% %  % sK   CB) :C"B; -<C)B84C7B88C;C
C	C

CFT)

startswithr   r   nx
MultiGraphadd_nodes_fromr   has_edgeadd_edgeGraph)stringccharsr'   r:   r   r$   
multigraphr8   r   r+   r   s   &         @@r   from_sparse6_bytesrG   i   s   D ((T""?@@#BZ(ZVVZE(GAt	A
q&1*	Q< 	
A
AU1XJ6FA6QVUAzz!!
JJq  HHQKHq )s   E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    )subgraphr=   convert_node_labels_to_integersjoinr,   )r$   r%   r&   s   &&&r   to_sparse6_bytesrO      sB    X JJu
**1x@A88+Af=>>rK   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"   rG   )pathglistlines   &  r   read_sparse6rW      sX    j Ezz|4yy'-.	 
 5zQQxrK   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    rI   )rL   r=   rM   r,   write)r$   rT   r%   r&   r8   s   &&&& r   write_sparse6r\   >  sG    r JJu
**1x@A$Qv6

1 7rK   )rG   rW   rO   r\   )NT)__doc__networkxr=   networkx.exceptionr   networkx.readwrite.graph6r   r   networkx.utilsr   r   __all__r,   _dispatchablerG   rO   rW   r\    rK   r   <module>re      s   
  , : 9
UOd T2^ 3^B/?d 14T2< 3 <~ Z 
14;  !;rK   