Ë
    GìjÊ%  ã                   óÞ   — d Z ddlZddlZddlmZ g d¢Zd„ Z edd¬«      dd	„«       Z edd
¬«       ej                  dd¬«      dd„«       «       Z
 ej                  dd¬«      d„ «       Zd„ Zy)a
  
*****
Pajek
*****
Read graphs in Pajek format.

This implementation handles directed and undirected graphs including
those with self loops and parallel edges.

Format
------
See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
for format information.

é    N)Ú	open_file)Ú
read_pajekÚparse_pajekÚgenerate_pajekÚwrite_pajekc              #   ó¶  K  — | j                   dk(  rd}n| j                   }d| j                  «       › �–— t        | «      }t        t	        |t        dt        |«      dz   «      «      «      }|D �]6  }| j                  j                  |i «      j                  «       }|j                  dd«      }|j                  dd«      }	 t        |j                  d||   «      «      }|||<   |j                  dd«      }
dj                  t        t         |||||
f«      «      }|j#                  «       D ]t  \  }}t%        |t&        «      r1|j)                  «       dk7  r|dt!        |«      › dt!        |«      › �z  }ŒGt+        j,                  d|› dt%        |t&        «      rdnd› d�«       Œv |–— �Œ9 | j/                  «       rd–— nd–— | j1                  d¬«      D ]Û  \  }}}|j                  «       }|j                  dd«      }dj                  t        t         ||   ||   |f«      «      }|j#                  «       D ]t  \  }}t%        |t&        «      r1|j)                  «       dk7  r|dt!        |«      › dt!        |«      › �z  }ŒGt+        j,                  d|› dt%        |t&        «      rdnd› d�«       Œv |–— ŒÝ y
# t        $ r}	|	xj                  d	z  c_        ‚ d
}	~	ww xY w­w)zðGenerate lines in Pajek graph format.

    Parameters
    ----------
    G : graph
       A Networkx graph

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    Ú ÚNetworkXz
*vertices é   Úxg        ÚyÚid)zSPajek format requires 'id' to be an int(). Refer to the 'Relabeling nodes' section.NÚshapeÚellipseÚ zNode attribute z is not processed. zEmpty attributezNon-string attributeÚ.ú*arcsú*edgesT)ÚdataÚweightg      ð?zEdge attribute )ÚnameÚorderÚlistÚdictÚzipÚrangeÚlenÚnodesÚgetÚcopyÚpopÚintÚ
ValueErrorÚargsÚjoinÚmapÚ	make_qstrÚitemsÚ
isinstanceÚstrÚstripÚwarningsÚwarnÚis_directedÚedges)ÚGr   r   Ú
nodenumberÚnÚnar   r   r   Úerrr   ÚsÚkÚvÚuÚedgedataÚdÚvalues                     ú\C:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\networkx/readwrite/pajek.pyr   r      s·  è ø€ ð 	‡v�v�‚|Ø‰à�v‰vˆð �q—w‘w“y�kÐ
"Ò"Ü�‹G€Eä”c˜%¤ q¬#¨e«*°q©.Ó!9Ó:Ó;€JÜˆð �W‰W�[‰[˜˜BÓ×$Ñ$Ó&ˆØ�F‰F�3˜ÓˆØ�F‰F�3˜Óˆð		Ü�R—V‘V˜D *¨Q¡-Ó0Ó1ˆBð ˆ
�1‰Ø—‘�w 	Ó*ˆØ�H‰H”Sœ R¨¨A¨q°%Ð$8Ó9Ó:ˆà—H‘H–J‰DˆAˆqÜ˜!œSÔ! a§g¡g£i°2¢oØ�qœ 1›˜ a¬	°!« ~Ð6Ñ6‘ä—‘Ø% a SÐ(;ÔR\Ð]^Ô`cÔRdÑ=Nð  kAð  <Cð  CDð  Eõð	 ð Œð7 ð< 	‡}�}„Ø‹àŠØŸ'™' t˜'Ö,‰ˆˆ1ˆhØ�M‰M‹OˆØ—‘�h Ó$ˆØ�H‰H”Sœ Z°¡]°J¸q±MÀ5Ð$IÓJÓKˆØ—G‘G–I‰DˆAˆqÜ˜!œSÔ! a§g¡g£i°2¢oØ�qœ 1›˜ a¬	°!« ~Ð6Ñ6‘ä—‘Ø% a SÐ(;ÔR\Ð]^Ô`cÔRdÑ=Nð  kAð  <Cð  CDð  Eõð	 ð ‹ñ -øô5 ò 	Ø�HŠHð ñ �Hð ûð	üs+   ‚B>KÃJ2ÃGKÊ2	KÊ;KËKËKr   Úwb)Úmodec                 ón   — t        | «      D ]'  }|dz  }|j                  |j                  |«      «       Œ) y)aO  Write graph in Pajek format to path.

    Parameters
    ----------
    G : graph
       A Networkx graph
    path : file or string
       File or filename to write.
       Filenames ending in .gz or .bz2 will be compressed.

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

    >>> fpath = tmp_path / "test.net"
    >>> G = nx.path_graph(4)
    >>> nx.write_pajek(G, fpath)

    >>> with open(fpath) as fh:  # The data as stored in pajek format
    ...     print(fh.read())
    *vertices 4
    1 0 0.0 0.0 ellipse
    2 1 0.0 0.0 ellipse
    3 2 0.0 0.0 ellipse
    4 3 0.0 0.0 ellipse
    *edges
    1 2 1.0
    2 3 1.0
    3 4 1.0
    <BLANKLINE>

    Warnings
    --------
    Optional node attributes and edge attributes must be non-empty strings.
    Otherwise it will not be written into the file. You will need to
    convert those attributes to strings if you want to keep them.

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    Ú
N)r   ÚwriteÚencode)r0   ÚpathÚencodingÚlines       r<   r   r   c   s2   € ô\ ˜qÖ!ˆØ�‰ˆØ�
‰
�4—;‘;˜xÓ(Õ)ñ "ó    ÚrbT)ÚgraphsÚreturns_graphc                 ó0   ‡— ˆfd„| D «       }t        |«      S )al  Read graph in Pajek 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 : NetworkX MultiGraph or MultiDiGraph.

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

    >>> fpath = tmp_path / "test.net"
    >>> nx.write_pajek(nx.path_graph(4), fpath)
    >>> G = nx.read_pajek(fpath)
    >>> G.edges
    MultiEdgeView([('0', '1', 0), ('1', '2', 0), ('2', '3', 0)])

    To create a Graph instead of a MultiGraph use

    >>> G1 = nx.Graph(G)
    >>> G1.edges
    EdgeView([('0', '1'), ('1', '2'), ('2', '3')])

    References
    ----------
    See http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/draweps.htm
    for format information.
    c              3   ó@   •K  — | ]  }|j                  ‰«      –— Œ y ­w)N)Údecode)Ú.0rE   rD   s     €r<   Ú	<genexpr>zread_pajek.<locals>.<genexpr>¼   s   øè ø€ Ð4©t tˆT�[‰[˜×"©tùs   ƒ)r   )rC   rD   Úliness    ` r<   r   r   –   s   ø€ óL 5©tÓ4€EÜ�uÓÐrF   c                 ó&	  ‡— ddl }t        | t        «      rt        | j	                  d«      «      } t        | D �cg c]  }|j                  d«      ‘Œ c}«      } t        j                  «       }g Š| �r–	 t        | «      }|j                  «       j                  d«      r'	 |j	                  dd«      \  }}||j                  d<   �n@|j                  «       j                  d«      �r8i }|j	                  «       \  }}t        t        |«      «      D �]	  }	t        | «      }	 |j	                  t        |«      j                  d«      «      D �
cg c]  }
|
j!                  d«      ‘Œ }}
|dd	 \  }}‰j%                  |«       |j'                  |«       |||<   ||j(                  |   d
<   	 |d	d \  }
}}|j(                  |   j+                  t-        |
«      t-        |«      |dœ«       t/        |ddd	…   |ddd	…   «      }|j(                  |   j+                  |«       �Œ �nè|j                  «       j                  d«      s |j                  «       j                  d«      �rP|j                  «       j                  d«      rt        j0                  |«      }|j                  «       j                  d«      r|j3                  «       }| D ]ç  }	 |j	                  t        |«      j                  d«      «      D �
cg c]  }
|
j!                  d«      ‘Œ }}
t5        |«      d	k  rŒX|dd	 \  }}j7                  ||«      }|j7                  ||«      }i }	 |d	d }|j+                  dt-        |d   «      i«       t/        |ddd	…   |ddd	…   «      }|j+                  |«        |j8                  ||fi |¤Ž Œé nY|j                  «       j                  d«      r:t        j:                  |«      }ˆfd„t=        | «      D «       }|j?                  |«       | r�Œ–|S c c}w #  Y |S xY w# t        $ r Y Œw xY wc c}
w # t"        $ r |j	                  t        |«      «      }Y �Œïw xY w#  Y �ŒyxY wc c}
w # t"        $ r |j	                  t        |«      «      }Y �Œw xY w#  Y �Œ&xY w)zìParse Pajek format graph from string or iterable.

    Parameters
    ----------
    lines : string or iterable
       Data in Pajek format.

    Returns
    -------
    G : NetworkX graph

    See Also
    --------
    read_pajek

    r   Nr@   z*networkr   r   z	*verticeszutf-8é   r   é   )r   r   r   é   r   r   z*edgeé   r   é   z*matrixc              3   ó®   •K  — | ]L  \  }}t        |j                  «       «      D ]+  \  }}t        |«      d k7  r‰|   ‰|   dt        |«      if–— Œ- ŒN y­w)r   r   N)Ú	enumerateÚsplitr"   )rM   ÚrowrE   Úcolr   Úlabelss        €r<   rN   zparse_pajek.<locals>.<genexpr>%  s]   øè ø€ ð á#3‘K�S˜$Ü#,¨T¯Z©Z«\Ö#:‘K�S˜$Ü�t“9 ’>ð ˜‘˜f S™k¨H´c¸$³iÐ+@ÔAà#:ð BÙ#3ùs   ƒAA) Úshlexr)   r*   ÚiterrX   ÚrstripÚnxÚMultiDiGraphÚnextÚlowerÚ
startswithÚgraphr#   r   r"   rB   rL   ÚAttributeErrorÚappendÚadd_noder   ÚupdateÚfloatr   Ú
MultiGraphÚto_directedr   r   Úadd_edgeÚDiGraphrW   Úadd_edges_from)rO   r\   rE   r0   ÚlÚlabelr   Ú
nodelabelsÚnnodesÚir   Ú	splitliner   r   r   Ú
extra_attrÚuiÚvir8   r7   Ú	edge_dataÚwÚadj_listr[   s                          @r<   r   r   À   s5  ø€ ó$ ô �%œÔÜ�U—[‘[ Ó&Ó'ˆÜ±Ó6±¨�$—+‘+˜dÕ#°Ñ6Ó7€EÜ
�‰Ó€AØ€FÚ
ð	Ü�U“ˆAð �7‰7‹9×Ñ 
Ô+ð'ØŸg™g d¨AÓ.‘��tð
 #'�—‘˜“Ø�W‰W‹Y×!Ñ! +Õ.ØˆJØŸ™›	‰IˆAˆvÜœ3˜v›;×'�Ü˜“K�ð4à38·;±;¼sÀ1»v¿}¹}ÈWÓ?UÔ3Vó!Ù3V¨a˜Ÿ™ Õ)Ð3Vð ð !ð
 & a¨˜N‘	��EØ—‘˜eÔ$Ø—
‘
˜5Ô!Ø!&�
˜2‘Ø')�—‘˜‘˜tÑ$ðØ"+¨A¨a .‘K�A�q˜%Ø—G‘G˜E‘N×)Ñ)Ü# A›h¬U°1«XÀÑFôô
 ! ¨1¨4¨a¨4¡°)¸A¸D¸q¸D±/ÓB�
Ø—‘˜‘×%Ñ% jÖ1ò+ (ð, �W‰W‹Y×!Ñ! (Ô+¨q¯w©w«y×/CÑ/CÀGÕ/LØ�w‰w‹y×#Ñ# GÔ,ä—M‘M !Ó$�Ø�w‰w‹y×#Ñ# GÔ,à—M‘M“O�Û�ð4à38·;±;¼sÀ1»v¿}¹}ÈWÓ?UÔ3Vó!Ù3V¨a˜Ÿ™ Õ)Ð3Vð ð !ô �y“> AÒ%ØØ" 1 Q˜‘��BØ—N‘N 2 rÓ*�Ø—N‘N 2 rÓ*�à�	ðà! ! A˜�AØ×$Ñ$ h´°a¸±d³Ð%<Ô=ô
 ! ¨1¨4¨a¨4¡°)¸A¸D¸q¸D±/ÓB�
Ø× Ñ  Ô,ð �—
‘
˜1˜aÑ- 9Ó-ñ7 ð8 �W‰W‹Y×!Ñ! )Ô,Ü—
‘
˜1“ˆAóä#,¨UÔ#3óˆHð ×Ñ˜XÔ&óc ðf €Hùòm 7øð	Øð^ €HûôW ò áðüò!øô &ò 4Ø %§¡¬C°«FÓ 3“Ið4ûðÚüò!øô &ò 4Ø %§¡¬C°«FÓ 3“Ið4ûðÚúsƒ   ¹P	Á2P ÂP Ä+P*ÅP%ÅP*Æ#=QË+Q!Ë.QÌQ!Í$RÐPÐ	P"Ð!P"Ð%P*Ð*#QÑQÑQÑQ!Ñ!#RÒRÒRc                 ó°   — t        | t        «      st        | «      } t        d„ | D «       «      r(| j                  dd«      j                  dd«      } d| › d�} | S )a  Returns the string representation of t.

    Wrap the string in double-quotes if it contains whitespace, a double
    quote, or a backslash, escaping the latter two so the Pajek reader
    (which splits with shlex) recovers the original string unchanged.
    c              3   óH   K  — | ]  }|j                  «       xs |d v –— Œ y­w)z"\N)Úisspace)rM   Úcs     r<   rN   zmake_qstr.<locals>.<genexpr>9  s#   è ø€ Ð
0©a¨ˆ1�9‰9‹;Ò$˜!˜u˜*Ó$©aùs   ‚ "Ú\z\\Ú"z\")r)   r*   ÚanyÚreplace)Úts    r<   r'   r'   0  sT   € ô �aœÔÜ�‹FˆÜ
Ñ
0©aÓ
0Ô0Ø�I‰I�d˜FÓ#×+Ñ+¨C°Ó7ˆØ�ˆs�!ˆHˆØ€HrF   )zUTF-8)Ú__doc__r,   Únetworkxr_   Únetworkx.utilsr   Ú__all__r   r   Ú_dispatchabler   r   r'   © rF   r<   Ú<module>rŠ      s›   ðñó  ã Ý $â
H€òGñT ˆ1�4Ôò/*ó ð/*ñd ˆ1�4ÔØ€×Ñ˜¨TÔ2ò%ó 3ó ð%ðP €×Ñ˜¨TÔ2ñló 3ðló^rF   