+
    �°³jB  ã                   ó   € R t . ROt^ RIt^ RIHt RR lt]! ^RR7      RR l4       t]P                  ! RRR7      RR	 l4       t	]! ^ R
R7      ]P                  ! RRR7      RR l4       4       t
RR lt]P                  ! RRR7      RR l4       tR# )aM  
**********
Edge Lists
**********
Read and write NetworkX graphs as edge lists.

The multi-line adjacency list format is useful for graphs with nodes
that can be meaningfully represented as strings.  With the edgelist
format simple edge data can be stored but node or graph data is not.
There is no way of representing isolated nodes unless the node has a
self-loop edge.

Format
------
You can read or write three formats of edge lists with these functions.

Node pairs with no data::

 1 2

Python dictionary as data::

 1 2 {'weight':7, 'color':'green'}

Arbitrary data::

 1 2 7 green
N)Ú	open_fileTc              #  ó  a"  € VRJ dM   V P                  RR7       F4  w  r4oW4\        S4      3pVP                  \        \        V4      4      x € K6  	  R# VRJ dB   V P                  RR7       F)  w  r4W43pVP                  \        \        V4      4      x € K+  	  R# V P                  RR7       FF  w  r4oW4.p VP                  V3R lV 4       4       VP                  \        \        V4      4      x € KH  	  R#   \         d     L4i ; i5i)aÕ  Generate lines representing edges of `G` in edge list format.

Parameters
----------
G : NetworkX graph

delimiter : str, optional (default=" ")
   Separator for node labels.

data : bool or list of keys
   If False generate no edge data.  If True use a dictionary
   representation of edge data.  If a list of keys use a list of data
   values corresponding to the keys.

Yields
------
str
    A line of data in edge list format for an edge in `G`.

Examples
--------
>>> G = nx.lollipop_graph(4, 3)
>>> G[1][2]["weight"] = 3
>>> G[3][4]["capacity"] = 12
>>> for line in nx.generate_edgelist(G, data=False):
...     print(line)
0 1
0 2
0 3
1 2
1 3
2 3
3 4
4 5
5 6

>>> for line in nx.generate_edgelist(G):
...     print(line)
0 1 {}
0 2 {}
0 3 {}
1 2 {'weight': 3}
1 3 {}
2 3 {}
3 4 {'capacity': 12}
4 5 {}
5 6 {}

>>> for line in nx.generate_edgelist(G, data=["weight"]):
...     print(line)
0 1
0 2
0 3
1 2 3
1 3
2 3
3 4
4 5
5 6

See Also
--------
write_edgelist, read_edgelist
T)ÚdataFc              3   ó6   <"  € T F  pSV,          x € K  	  R # 5i©N© )Ú.0ÚkÚds   & €Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/readwrite/edgelist.pyÚ	<genexpr>Ú$generate_edgelist.<locals>.<genexpr>x   s   øé € Ð,¡t !˜˜1Ÿš£tùs   ƒN)ÚedgesÚdictÚjoinÚmapÚstrÚextendÚKeyError)ÚGÚ	delimiterr   ÚuÚvÚer
   s   &&&   @r   Úgenerate_edgelistr   +   sê   øé € ðB ˆtƒ|Ø—w‘w D�wÖ)‰GˆA�!Ø”d˜1“g�ˆAØ—.‘.¤¤S¨!£Ó-Ô-ó *ð 
�‹Ø—G‘G �GÖ'‰DˆAØ�ˆAØ—.‘.¤¤S¨!£Ó-Ô-ó (ð —w‘w D�wÖ)‰GˆA�!Ø�ˆAðØ—‘Ô,¡tÓ,Ô,ð —.‘.¤¤S¨!£Ó-Ô-ó *øô ô Ùðüs*   ƒB5DÂ9C;Ã'DÃ;D	ÄDÄD	Ä	DÚwb)Úmodec                ó~   € \        WV4       F,  pVR,          pVP                  VP                  V4      4       K.  	  R# )a¸  Write graph as a list of edges.

Parameters
----------
G : graph
   A NetworkX graph
path : file or string
   File or filename to write. If a file is provided, it must be
   opened in 'wb' mode. Filenames ending in .gz or .bz2 will be compressed.
comments : string, optional
   The character used to indicate the start of a comment
delimiter : string, optional
   The string used to separate values.  The default is whitespace.
data : bool or list, optional
   If False write no edge data.
   If True write a string representation of the edge data dictionary..
   If a list (or other iterable) is provided, write the  keys specified
   in the list.
encoding: string, optional
   Specify which encoding to use when writing file.

Examples
--------
>>> from pathlib import Path
>>> import tempfile, gzip
>>> tmp_path = Path(tempfile.gettempdir())

>>> G = nx.path_graph(4)

Write out the edgelist to file:

>>> fpath = tmp_path / "test.edgelist"
>>> nx.write_edgelist(G, fpath)
>>> with open(fpath) as fh:
...     print(fh.read())
0 1 {}
1 2 {}
2 3 {}
<BLANKLINE>

A filename ending with ".gz" or ".bz2" will be automatically compressed:

>>> fpath = tmp_path / "test_edgelist.gz"
>>> nx.write_edgelist(G, fpath)
>>> with gzip.open(fpath) as fh:
...     print(fh.read().decode())
0 1 {}
1 2 {}
2 3 {}
<BLANKLINE>

The `data` parameter is used to toggle whether edge attribute data are
included:

>>> G = nx.Graph()
>>> G.add_edge(1, 2, weight=7, color="red")

>>> fpath = tmp_path / "test.edgelist"
>>> nx.write_edgelist(G, fpath, data=False)
>>> with open(fpath) as fh:
...     print(fh.read())
1 2
<BLANKLINE>

Or to specify which edge attribute data to include:

>>> nx.write_edgelist(G, fpath, data=["color"])
>>> with open(fpath) as fh:
...     print(fh.read())
1 2 red
<BLANKLINE>

>>> nx.write_edgelist(G, fpath, data=["color", "weight"])
>>> with open(fpath) as fh:
...     print(fh.read())
1 2 red 7
<BLANKLINE>

See Also
--------
read_edgelist
write_weighted_edgelist
Ú
N)r   ÚwriteÚencode)r   ÚpathÚcommentsr   r   ÚencodingÚlines   &&&&&& r   Úwrite_edgelistr%   ~   s4   € ôl " !°Ö5ˆØ��ˆØ�
‰
�4—;‘;˜xÓ(Ö)ó 6ó    )ÚgraphsÚreturns_graphc                ó(  € ^ RI Hp \        P                  ! ^ V4      pV  EFx  pVe(   VP	                  V4      p	V	^ 8¼  d   VRV	 pV'       g   K/  VP                  R4      P                  V4      p
\        V
4      ^8  d   Ka  V
P                  ^ 4      pV
P                  ^ 4      pT
pVe    V! V4      pV! V4      p\        V4      ^ 8X  g   VRJ d   / pM²VR	J dL    VR8X  d   RP                  V4      pMR
P                  V4      p\        V! VP                  4       4      4      pMa\        V4      \        V4      8w  d   \        RV RV R24      h/ p\        W]4       F%  w  w  ppp V! V4      pTP!                  TT/4       K'  	  VP"                  ! W¼3/ VB  EK{  	  V#   \         d   p\        RT RT RT R24      ThRp?ii ; i  \         d   p\        RT R24      ThRp?ii ; i  \         d   p\        RT RT RT R24      ThRp?ii ; i)a  Parse lines of an edge list representation of a graph.

Parameters
----------
lines : list or iterator of strings
    Input data in edgelist format
comments : string, optional
   Marker for comment lines. Default is `'#'`. To specify that no character
   should be treated as a comment, use ``comments=None``.
delimiter : string, optional
   Separator for node labels. Default is `None`, meaning any whitespace.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
   Graph type to create. If graph instance, then cleared before populated.
nodetype : Python type, optional
   Convert nodes to this type. Default is `None`, meaning no conversion is
   performed.
data : bool or list of (label,type) tuples
   If `False` generate no edge data or if `True` use a dictionary
   representation of edge data or a list tuples specifying dictionary
   key names and types for edge data.

Returns
-------
G: NetworkX Graph
    The graph corresponding to lines

Examples
--------
Edgelist with no data:

>>> lines = ["1 2", "2 3", "3 4"]
>>> G = nx.parse_edgelist(lines, nodetype=int)
>>> list(G)
[1, 2, 3, 4]
>>> list(G.edges())
[(1, 2), (2, 3), (3, 4)]

Edgelist with data in Python dictionary representation:

>>> lines = ["1 2 {'weight': 3}", "2 3 {'weight': 27}", "3 4 {'weight': 3.0}"]
>>> G = nx.parse_edgelist(lines, nodetype=int)
>>> list(G)
[1, 2, 3, 4]
>>> list(G.edges(data=True))
[(1, 2, {'weight': 3}), (2, 3, {'weight': 27}), (3, 4, {'weight': 3.0})]

Edgelist with data in a list:

>>> lines = ["1 2 3", "2 3 27", "3 4 3.0"]
>>> G = nx.parse_edgelist(lines, nodetype=int, data=(("weight", float),))
>>> list(G)
[1, 2, 3, 4]
>>> list(G.edges(data=True))
[(1, 2, {'weight': 3.0}), (2, 3, {'weight': 27.0}), (3, 4, {'weight': 3.0})]

See Also
--------
read_weighted_edgelist
)Úliteral_evalNr   zFailed to convert nodes Ú,z	 to type Ú.FTÚ zFailed to convert edge data (z) to dictionary.z
Edge data z and data_keys z are not the same lengthzFailed to convert z data )Úastr*   ÚnxÚempty_graphÚfindÚrstripÚsplitÚlenÚpopÚ	ExceptionÚ	TypeErrorr   r   ÚstripÚ
IndexErrorÚzipÚupdateÚadd_edge)Úlinesr"   r   Úcreate_usingÚnodetyper   r*   r   r$   ÚpÚsr   r   r
   ÚerrÚedgedataÚedgedata_strÚedge_keyÚ	edge_typeÚ
edge_values   &&&&&&              r   Úparse_edgelistrH   Ù   sJ  € õ~ !ä
�Š�q˜,Ó'€AÜˆØÒØ—	‘	˜(Ó#ˆAØ�AŒvØ˜B˜Q�x�ßÙà�K‰K˜Ó×#Ñ# IÓ.ˆÜˆq‹6�AŒ:ÙØ�E‰E�!‹HˆØ�E‰E�!‹HˆØˆØÒðÙ˜Q“K�Ù˜Q“K�ô ˆq‹6�QŒ;˜$ %›-à‰HØ�T‹\ð	Ø Ô#Ø#&§8¡8¨A£;‘Là#&§8¡8¨A£;�LÜ¡¨\×-?Ñ-?Ó-AÓ BÓC‘ô �1‹vœ˜T›Ô"Ü Ø    ?°4°&Ð8PÐQóð ð ˆHÜ58¸¶\Ñ1Ñ%�˜9 zðÙ!*¨:Ó!6�Jð —‘ ¨:Ð 6Ö7ñ 6Bð 	
�
Š
�1Ñ$˜8Õ$ñm ðn €HøôK ô ÜØ.¨q¨c°°1°#°Y¸x¸jÈÐJóàðûðûô  ô ÜØ3°A°3Ð6FÐGóàðûðûô !ô Ü#Ø,¨X¨J°f¸Z¸Lð I#Ø#, +¨Qð0óð ðûðúsI   Â*FÃA	GÅ&G+ÆGÆ*G Ç GÇG(ÇG#Ç#G(Ç+HÇ6HÈHÚrbc           	     ó>   a€ V3R lV  4       p\        VVVVVVR7      # )aí  Read a graph from a list of edges.

Parameters
----------
path : file or string
   File or filename to read. If a file is provided, it must be
   opened in 'rb' mode.
   Filenames ending in .gz or .bz2 will be decompressed.
comments : string, optional
   The character used to indicate the start of a comment. To specify that
   no character should be treated as a comment, use ``comments=None``.
delimiter : string, optional
   The string used to separate values.  The default is whitespace.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
   Graph type to create. If graph instance, then cleared before populated.
nodetype : int, float, str, Python type, optional
   Convert node data from strings to specified type
data : bool or list of (label,type) tuples
   Tuples specifying dictionary key names and types for edge data
edgetype : int, float, str, Python type, optional OBSOLETE
   Convert edge data from strings to specified type and use as 'weight'
encoding: string, optional
   Specify which encoding to use when reading file.

Returns
-------
G : graph
   A networkx Graph or other type specified with create_using

Examples
--------
>>> from pathlib import Path
>>> import tempfile
>>> tmp_path = Path(tempfile.gettempdir())

>>> fpath = tmp_path / "P4.edgelist"
>>> nx.write_edgelist(nx.path_graph(4), fpath)
>>> G = nx.read_edgelist(fpath)
>>> G.edges
EdgeView([('0', '1'), ('1', '2'), ('2', '3')])

Nodes read from the file are interpreted as strings by default. The `nodetype`
parameter can be used to convert the nodes to another type:

>>> G = nx.read_edgelist(fpath, nodetype=int)
>>> G.edges
EdgeView([(0, 1), (1, 2), (2, 3)])

The optional `create_using` parameter indicates the type of NetworkX
graph created. By default an undirected ``nx.Graph`` is returned. To read
the data as a directed graph use:

>>> G = nx.read_edgelist(fpath, create_using=nx.DiGraph)
>>> G.is_directed()
True

By default, edge data is expected to be stored in a serialized dict-like
format keyed by the attribute name:

>>> fpath = tmp_path / "test.text"
>>> with open(fpath, "w") as fh:  # Create a file with data in default format
...     _ = fh.write("1 2 {'weight': 3}")

>>> G = nx.read_edgelist(fpath, nodetype=int)
>>> G.edges(data=True)
EdgeDataView([(1, 2, {'weight': 3})])

Alternatively, edge data stored as a flat list without keys can be parsed
by passing in the attribute name and data type via `data`:

>>> textline = "1 2 red 10"
>>> fpath = tmp_path / "test.textline"
>>> with open(fpath, "w") as fh:  # Create a file with flattened edge data
...     _ = fh.write(textline)

>>> G = nx.read_edgelist(
...     fpath, nodetype=int, data=[("color", str), ("weight", float)]
... )
>>> G.edges(data=True)
EdgeDataView([(1, 2, {'color': 'red', 'weight': 10.0})])

See `parse_edgelist` for more examples of formatting.

See Also
--------
parse_edgelist
write_edgelist

Notes
-----
Since nodes must be hashable, the function nodetype must return hashable
types (e.g. int, float, str, frozenset - or tuples of those, etc.)
c              3   óv   <"  € T F.  p\        V\        4      '       d   TMVP                  S4      x € K0  	  R # 5ir   )Ú
isinstancer   Údecode)r   r$   r#   s   & €r   r   Ú read_edgelist.<locals>.<genexpr>¾  s-   øé € ÐWÑRVÈ$”Z ¤c×*Ò*‰T°·±¸HÓ0EÔEÓRVùs   ƒ69)r"   r   r>   r?   r   )rH   )	r!   r"   r   r>   r?   r   Úedgetyper#   r=   s	   &&&&&&&f r   Úread_edgelistrP   U  s1   ø€ ôR XÑRVÓW€EÜØØØØ!ØØôð r&   c           	     ó(   € \        V VVVRVR7       R# )a   Write graph `G` as a list of edges with numeric weights.

Parameters
----------
G : graph
   A NetworkX graph
path : file or string
   File or filename to write. If a file is provided, it must be
   opened in 'wb' mode.
   Filenames ending in .gz or .bz2 will be compressed.
comments : string, optional
   The character used to indicate the start of a comment
delimiter : string, optional
   The string used to separate values.  The default is whitespace.
encoding: string, optional
   Specify which encoding to use when writing file.

Examples
--------
>>> from pathlib import Path
>>> import tempfile
>>> tmp_path = Path(tempfile.gettempdir())

>>> G = nx.Graph()
>>> G.add_edge(1, 2, weight=7)
>>> fpath = tmp_path / "test.weighted.edgelist"
>>> nx.write_weighted_edgelist(G, fpath)
>>> with open(fpath) as fh:
...     print(fh.read())
1 2 7
<BLANKLINE>

See Also
--------
read_edgelist
write_edgelist
read_weighted_edgelist
)r"   r   r   r#   N)Úweight)r%   )r   r!   r"   r   r#   s   &&&&&r   Úwrite_weighted_edgelistrS   É  s   € ôN Ø	ØØØØØ÷r&   c           
     ó4   € \        V VVVVR\        33VR7      # )a|  Read a graph as list of edges with numeric weights.

Parameters
----------
path : file or string
   File or filename to read. If a file is provided, it must be
   opened in 'rb' mode.
   Filenames ending in .gz or .bz2 will be decompressed.
comments : string, optional
   The character used to indicate the start of a comment.
delimiter : string, optional
   The string used to separate values.  The default is whitespace.
create_using : NetworkX graph constructor, optional (default=nx.Graph)
   Graph type to create. If graph instance, then cleared before populated.
nodetype : int, float, str, Python type, optional
   Convert node data from strings to specified type
encoding: string, optional
   Specify which encoding to use when reading file.

Returns
-------
G : graph
   A networkx Graph or other type specified with create_using

Notes
-----
Since nodes must be hashable, the function nodetype must return hashable
types (e.g. int, float, str, frozenset - or tuples of those, etc.)

Examples
--------
>>> from pathlib import Path
>>> import tempfile, gzip
>>> tmp_path = Path(tempfile.gettempdir())

read_weighted_edgelist expected data of the form ``u v w``, as is generated
by `write_weighted_edgelist`:

>>> G = nx.Graph()
>>> G.add_weighted_edges_from([(0, 1, 1), (1, 2, 2.718), (2, 0, 10)])
>>> fpath = tmp_path / "C3_weighted.list"
>>> nx.write_weighted_edgelist(G, fpath)
>>> with open(fpath) as fh:
...     print(fh.read())
0 1 1
0 2 10
1 2 2.718
<BLANKLINE>

>>> H = nx.read_weighted_edgelist(fpath, nodetype=int)
>>> H.edges(data="weight")
EdgeDataView([(0, 1, 1.0), (0, 2, 10.0), (1, 2, 2.718)])

See Also
--------
write_weighted_edgelist
rR   )r"   r   r>   r?   r   r#   )rP   Úfloat)r!   r"   r   r>   r?   r#   s   &&&&&&r   Úread_weighted_edgelistrV   ú  s/   € ôD ØØØØ!ØØœÐÐ!Øôð r&   )r   r%   rH   rP   rV   rS   )r-   T)Ú#r-   Túutf-8)rW   NNNT)rW   NNNTNrX   )rW   r-   rX   )rW   NNNrX   )Ú__doc__Ú__all__Únetworkxr/   Únetworkx.utilsr   r   r%   Ú_dispatchablerH   rP   rS   rV   r   r&   r   Ú<module>r^      s¾   ðñò:€ó Ý $ôP.ñf ˆ1�4ÔóW*ó ðW*ðt ×Ò˜¨TÔ2óxó 3ðxñv ˆ1�4ÔØ×Ò˜¨TÔ2óoó 3ó ðoôd.ðb ×Ò˜¨TÔ2óIó 3òIr&   