+
    �°³j8x  ã                   ó°  € R t ^ RIHt ^ RIt^ RIHt RR.t]P                  R 4       t	R t
R#R ltR	 tR
 tR tR$R lt]P                  ! RRR7      R%R l4       t]P                  R 4       t]P                  ! RR7      R%R l4       t]P                  R 4       tR tR tR tR tR tR tR tR tR&R ltR tR tR t]! ^4      R%R  l4       t R! t!R" t"R# )'z?
Threshold Graphs - Creation, manipulation and identification.
)ÚsqrtN)Úpy_random_stateÚis_threshold_graphÚfind_threshold_graphc                óh   € \        V P                  4        UUu. uF  w  rVNK	  	  upp4      # u uppi )a   
Returns `True` if `G` is a threshold graph.

Parameters
----------
G : NetworkX graph instance
    An instance of `Graph`, `DiGraph`, `MultiGraph` or `MultiDiGraph`

Returns
-------
bool
    `True` if `G` is a threshold graph, `False` otherwise.

Examples
--------
>>> from networkx.algorithms.threshold import is_threshold_graph
>>> G = nx.path_graph(3)
>>> is_threshold_graph(G)
True
>>> G = nx.barbell_graph(3, 3)
>>> is_threshold_graph(G)
False

References
----------
.. [1] Threshold graphs: https://en.wikipedia.org/wiki/Threshold_graph
)Úis_threshold_sequenceÚdegree)ÚGÚnÚds   &  Ú^/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/threshold.pyr   r      s)   € ô: !°·±´
Ô!;±
©¨£!±
Ò!;Ó<Ð<ùÓ!;s   ™.
c                ó&  € V R,          pVP                  4        V'       dk   V^ ,          ^ 8X  d   VP                  ^ 4       K)  VR,          \        V4      ^,
          8w  d   R# VP                  4        V Uu. uF  q"^,
          NK  	  ppKr  R# u upi )at  
Returns True if the sequence is a threshold degree sequence.

Uses the property that a threshold graph must be constructed by
adding either dominating or isolated nodes. Thus, it can be
deconstructed iteratively by removing a node of degree zero or a
node that connects to the remaining nodes.  If this deconstruction
fails then the sequence is not a threshold sequence.
ºNNNFTéÿÿÿÿ)ÚsortÚpopÚlen)Údegree_sequenceÚdsr   s   &  r   r   r   -   su   € ð 
˜Õ	€BØ‡G�G„Iß
Øˆa�5�AŒ:Ø�F‰F�1ŒIÙØˆb�6”S˜“W˜q•[Ô ÙØ
�‰ŒÙÓ ™R˜�!�eˆe™RˆÐ ‰Ùùò !s   Á7Bc                óh  € V'       d   V'       d   \        R4      h\        V \        4      '       d&   V P                  4        UUu. uF  w  r4WC.NK
  	  pppM\	        V 4       UUu. uF  w  rgWv.NK
  	  pppVP                  4        . pV'       dÚ   V^ ,          ^ ,          ^ 8X  dO   VP                  ^ 4      w  ry\        V4      ^ 8”  d   VP                  ^ V	R34       MVP                  ^ V	R34       Kk  VR,          ^ ,          \        V4      ^,
          8w  d   R# VP                  4       w  ryVP                  ^ V	R34       V Uu. uF  qw^ ,          ^,
          V^,          .NK  	  ppKá  V'       d   V# V'       d   \        V4      # V U	u. uF  q™^,          NK  	  up	# u uppi u uppi u upi u up	i )a–  
Determines the creation sequence for the given threshold degree sequence.

The creation sequence is a list of single characters 'd'
or 'i': 'd' for dominating or 'i' for isolated vertices.
Dominating vertices are connected to all vertices present when it
is added.  The first node added is by convention 'd'.
This list can be converted to a string if desired using "".join(cs)

If with_labels==True:
Returns a list of 2-tuples containing the vertex number
and a character 'd' or 'i' which describes the type of vertex.

If compact==True:
Returns the creation sequence in a compact form that is the number
of 'i's and 'd's alternating.
Examples:
[1,2,2,3] represents d,i,i,d,d,i,i,i
[3,1,2] represents d,d,d,i,d,d

Notice that the first number is the first vertex to be used for
construction and so is always 'd'.

with_labels and compact cannot both be True.

Returns None if the sequence is not a threshold sequence
ú#compact sequences cannot be labeledÚir   Nr   )
Ú
ValueErrorÚ
isinstanceÚdictÚitemsÚ	enumerater   r   r   ÚinsertÚmake_compact)
r   Úwith_labelsÚcompactÚlabelr   r   r   r   ÚcsÚvs
   &&&       r   Úcreation_sequencer$   D   sj  € ÷8 —wÜÐ>Ó?Ð?ô �/¤4×(Ò(Ø5D×5JÑ5JÔ5LÔMÑ5L¡/ 5ˆv‹oÑ5LˆÑMˆä!*¨?Ô!;Ô<Ñ!;™˜ˆq‹fÑ!;ˆÑ<Ø‡G�G„IØ	€Bß
Øˆa�5��8�qŒ=Ø—V‘V˜A“Y‰FˆQÜ�2‹w˜Œ{Ø—	‘	˜!˜a ˜XÕ&à—	‘	˜!˜a ˜XÔ&ÙØˆb�6�!�9œ˜B› !�Ô#ÙØ—‘“‰ˆØ
�	‰	�!�a˜�XÔÙ(*Ó+© 1��t�a�x˜˜1�Ó©ˆÐ+‰çØˆ	ßÜ˜BÓÐÙÓ™"�Qˆa�DˆD™"ÑÐùó/ Nùã<ùò ,ùò s   ÁFÁ%F$Å!F*Æ
F/c                óÖ  € V ^ ,          p\        V\        4      '       d   V R,          pMQ\        V\        4      '       d   V  Uu. uF  q3^,          NK  	  ppM#\        V\        4      '       d   V # \	        R4      h. p^p\        ^\        V4      4       F;  pW&,          W&^,
          ,          8X  d   V^,          pK(  VP                  V4       ^pK=  	  VP                  V4       V# u upi )a  
Returns the creation sequence in a compact form
that is the number of 'i's and 'd's alternating.

Examples
--------
>>> from networkx.algorithms.threshold import make_compact
>>> make_compact(["d", "i", "i", "d", "d", "i", "i", "i"])
[1, 2, 2, 3]
>>> make_compact(["d", "d", "d", "i", "d", "d"])
[3, 1, 2]

Notice that the first number is the first vertex
to be used for construction and so is always 'd'.

Labeled creation sequences lose their labels in the
compact representation.

>>> make_compact([3, 1, 2])
[3, 1, 2]
r   ú"Not a valid creation sequence type)r   ÚstrÚtupleÚintÚ	TypeErrorÚranger   Úappend)r$   Úfirstr"   ÚsÚccsÚcountr   s   &      r   r   r      sÎ   € ð, ˜aÕ €EÜ�%œ×ÒØ˜qÕ!‰Ü	�Eœ5×	!Ò	!Ù-Ó.Ñ-�q��dˆdÑ-ˆÐ.ˆÜ	�Eœ3×	Ò	Ø Ð äÐ<Ó=Ð=à
€CØ€EÜ�1”c˜"“gÖˆØ�5�B˜1•u•IÔØ�Q�JŠEà�J‰J�uÔØŠEñ ð ‡J�JˆuÔØ€Jùò /s   ÁC&c                óš  € V ^ ,          p\        V\        4      '       d   V # \        V\        4      '       d   V # \        V\        4      '       d   V R,          pM\	        R4      h. pV'       d]   VP                  VP                  ^ 4      R.,          4       V'       g   K:  VP                  VP                  ^ 4      R.,          4       Kd  V# )z¹
Converts a compact creation sequence for a threshold
graph to a standard creation sequence (unlabeled).
If the creation_sequence is already standard, return it.
See creation_sequence.
r   r&   r   r   )r   r'   r(   r)   r*   Úextendr   )r$   r-   Úccscopyr"   s   &   r   Ú	uncompactr4   «   sŸ   € ð ˜aÕ €EÜ�%œ×ÒØ Ð Ü	�Eœ5×	!Ò	!Ø Ð Ü	�Eœ3×	Ò	Ø# AÕ&‰äÐ<Ó=Ð=Ø	€Bß
Ø
�	‰	�'—+‘+˜a“. C 5Õ(Ô)ß‰7Ø�I‰I�g—k‘k !“n¨ uÕ,Ö-Ø€Ió    c                óè  € V ^ ,          p\        V\        4      '       d-   \        V \        4      '       d   V R,          pMg\        V 4      pM[\        V\        4      '       d   V  Uu. uF  q3^,          NK  	  ppM-\        V\        4      '       d   \        V 4      pM\        R4      hVP                  4        ^ pRp\        V4       F(  w  rgVR8X  d	   WBV&   TpK  VR8X  g   K  TpV^,          pK*  	  VP                  4        \        V4       F(  w  rgVR8X  d	   WBV&   TpK  VR8X  g   K  TpV^,          pK*  	  VR8X  d
   V^,          p^V,          pV U	u. uF  q™V,          NK  	  up	# u upi u up	i )zâ
Returns a list of node weights which create the threshold
graph designated by the creation sequence.  The weights
are scaled so that the threshold is 1.0.  The order of the
nodes is the same as that in the creation sequence.
r   r&   r   r   )	r   r'   Úlistr(   r)   r4   r*   Úreverser   )
r$   r-   Úwseqr#   ÚwÚprevÚjr.   ÚwscaleÚwws
   &         r   Úcreation_sequence_to_weightsr?   Ã   sW  € ð ˜aÕ €EÜ�%œ×ÒÜÐ'¬×.Ò.Ø$ QÕ'‰DäÐ)Ó*‰DÜ	�Eœ5×	!Ò	!Ù/Ó0Ñ/˜�!—�Ñ/ˆÐ0ˆÜ	�Eœ3×	Ò	ÜÐ*Ó+‰äÐ<Ó=Ð=à‡L�L„NØ	€AØ€DÜ˜$–‰ˆØ�Œ8Ø�‰GØŠDØ�SŽ[ØˆDØ��FŠAñ  ð 	‡L�L„NÜ˜$–‰ˆØ�Œ8Ø�‰GØŠDØ�SŽ[ØˆDØ��FŠAñ  ð ˆs„{Ø	ˆQ�ˆØ��U€FÙ"&Ó'¡$˜B��KˆK¡$Ñ'Ð'ùò9 1ùò8 (s   Á&E*ÅE/c                óX  € V'       d   V'       d   \        R4      h\        V \        4      '       d&   V P                  4        UUu. uF  w  rEWT.NK
  	  pppM\	        V 4       UUu. uF  w  ruWW.NK
  	  pppVP                  4        . pWR,          ^ ,          ,
          p	V'       d±   V^ ,          ^ ,          V	8  d(   VP                  ^ 4      w  rTVP                  VR34       M;VP                  4       w  rTVP                  VR34       WR,          ^ ,          ,
          p	\        V4      ^8X  g   K‘  VP                  4       w  rTVP                  VR34       K¸  VP                  4        V'       d   V# V'       d   \        V4      # V U
u. uF  qª^,          NK  	  up
# u uppi u uppi u up
i )a¤  
Returns a creation sequence for a threshold graph
determined by the weights and threshold given as input.
If the sum of two node weights is greater than the
threshold value, an edge is created between these nodes.

The creation sequence is a list of single characters 'd'
or 'i': 'd' for dominating or 'i' for isolated vertices.
Dominating vertices are connected to all vertices present
when it is added.  The first node added is by convention 'd'.

If with_labels==True:
Returns a list of 2-tuples containing the vertex number
and a character 'd' or 'i' which describes the type of vertex.

If compact==True:
Returns the creation sequence in a compact form that is the number
of 'i's and 'd's alternating.
Examples:
[1,2,2,3] represents d,i,i,d,d,i,i,i
[3,1,2] represents d,d,d,i,d,d

Notice that the first number is the first vertex to be used for
construction and so is always 'd'.

with_labels and compact cannot both be True.
r   r   r   r   )r   r   r   r   r   r   r   r,   r   r8   r   )ÚweightsÚ	thresholdr   r    r!   r:   r9   r   r"   Úcutoffr#   s   &&&&       r   Úweights_to_creation_sequencerD   ò   sM  € ÷< —wÜÐ>Ó?Ð?ô �'œ4× Ò Ø-4¯]©]¬_Ô=©_™z �“
©_ˆÑ=ˆä#,¨WÔ#5Ô6Ñ#5™4˜1�“Ñ#5ˆÑ6Ø‡I�I„KØ	€BØ˜b� !�Õ$€Fß
Ø��7�1�:˜ÔØŸ™ !›‰JˆQØ�I‰I�u˜c�lÕ#àŸ™›‰JˆQØ�I‰I�u˜c�lÔ#Ø b¥¨!¥Õ,ˆFÜˆt‹9˜Ž>ØŸ™›‰JˆQØ�I‰I�u˜c�lÖ#à‡J�J„LçØˆ	ßÜ˜BÓÐÙÓ™"�Qˆa�DˆD™"ÑÐùó1 >ùã6ùò, s   ÁFÁ%F!ÆF'T)ÚgraphsÚreturns_graphc                ót  € V ^ ,          p\        V\        4      '       d   \        \        V 4      4      pMa\        V\        4      '       d   V R,          pMA\        V\
        4      '       d!   \        V 4      p\        \        V4      4      pM\        R4      h\        P                  ! ^ V4      pVP                  4       '       d   \        P                  ! R4      hRVn        V'       dQ   VP                  ^ 4      w  rgVR8X  d$   \        V4       F  pVP                  Wh4       K  	  VP                  V4       KX  V# )a¤  
Create a threshold graph from the creation sequence or compact
creation_sequence.

The input sequence can be a

creation sequence (e.g. ['d','i','d','d','d','i'])
labeled creation sequence (e.g. [(0,'d'),(2,'d'),(1,'i')])
compact creation sequence (e.g. [2,1,1,2,0])

Use cs=creation_sequence(degree_sequence,labeled=True)
to convert a degree sequence to a creation sequence.

Returns None if the sequence is not valid
r   znot a valid creation sequencezDirected Graph not supportedzThreshold Graphr   )r   r'   r7   r   r(   r)   r4   r   ÚnxÚempty_graphÚis_directedÚNetworkXErrorÚnamer   Úadd_edgeÚadd_node)	r$   Úcreate_usingr-   Úcir"   r	   r#   Ú	node_typeÚus	   &&       r   Úthreshold_graphrS   1  sð   € ð$ ˜aÕ €EÜ�%œ×ÒÜ”)Ð-Ó.Ó/‰Ü	�Eœ5×	!Ò	!Ø˜qÕ!‰Ü	�Eœ3×	Ò	ÜÐ(Ó)ˆÜ”)˜B“-Ó ‰äÐ8Ó9Ð9ä
�Š�q˜,Ó'€AØ‡}�}‡‚Ü×ÒÐ=Ó>Ð>à€A„F÷
 ØŸ™ ›‰ˆØ˜Ôô
 ˜!–W�Ø—
‘
˜1Ö ñ à	�
‰
�1ŽØ€Hr5   c                ó*  € V P                  4        F~  w  rV P                  4        Fe  pV P                  W4      '       d   K  W8w  g   K$  V P                  V4       F,  pV P                  W$4      '       d   K  W$8w  g   K$  WW4.u u u # 	  Kg  	  K€  	  R# )zŸ
Returns False if there aren't any alternating 4 cycles.
Otherwise returns the cycle as [a,b,c,d] where (a,b)
and (c,d) are edges and (a,c) and (b,d) are not.
F)ÚedgesÚnodesÚhas_edgeÚ	neighbors)r	   rR   r#   r:   Úxs   &    r   Úfind_alternating_4_cyclerZ   d  sm   € ð —‘–	‰ˆØ—‘–ˆAØ—:‘:˜a×#Ô#¨®ØŸ™ Qž�AØŸ:™: a×+Ô+°¶Ø ! a˜|Ö+ó (ó ñ ñ r5   )rF   c                ó,   € \        \        V 4      V4      # )a  
Returns a threshold subgraph that is close to largest in `G`.

The threshold graph will contain the largest degree node in G.

Parameters
----------
G : NetworkX graph instance
    An instance of `Graph`, or `MultiDiGraph`
create_using : NetworkX graph class or `None` (default), optional
    Type of graph to use when constructing the threshold graph.
    If `None`, infer the appropriate graph type from the input.

Returns
-------
graph :
    A graph instance representing the threshold graph

Examples
--------
>>> from networkx.algorithms.threshold import find_threshold_graph
>>> G = nx.barbell_graph(3, 3)
>>> T = find_threshold_graph(G)
>>> T.nodes  # may vary
NodeView((7, 8, 5, 6))

References
----------
.. [1] Threshold graphs: https://en.wikipedia.org/wiki/Threshold_graph
)rS   Úfind_creation_sequence)r	   rO   s   &&r   r   r   t  s   € ô@ Ô1°!Ó4°lÓCÐCr5   c           	     ó¬  € . pT pVP                  4       ^ 8”  Ed$   \        VP                  4       4      pVP                  4        UUu. uF  w  rEWT3NK
  	  pppVP	                  4        VR,          ^ ,          ^ 8X  d=   VP                  \        VR.\        V4      ^,
          ,          R.,           4      4       M…V^ ,          ^ ,          ^ 8X  d)   VP                  ^ 4      w  rWVP                  VR34       K=  VP                  4       w  rXVP                  VR34       VP                  VP                  V4      4      pEK9  VP                  4        V# u uppi )zy
Find a threshold subgraph that is close to largest in G.
Returns the labeled creation sequence of that threshold graph.
r   r   r   )Úorderr   r   r   r   r2   Úzipr   r   r,   ÚsubgraphrX   r8   )	r	   r"   ÚHÚdsdictr#   r   r   ÚisoÚbigvs	   &        r   r\   r\   —  s  € ð 
€Bà	€AØ
�'‰'‹)�a�-ä�a—h‘h“jÓ!ˆØ!'§¡¤Ô0¡™˜ˆq‹f¡ˆÑ0Ø
�‰Œ	àˆb�6�!�9˜Œ>Ø�I‰I”c˜& 3 %¬3¨r«7°Q­;Õ"7¸3¸%Õ"?Ó@ÔAØà��e�A�h˜!ŒmØ—v‘v˜a“y‰HˆQØ�I‰I�s˜C�jÖ!à—F‘F“H‰	ˆà
�	‰	�4˜�+Ôà�J‰J�q—{‘{ 4Ó(Ó)‹Ø‡J�J„LØ€Iùó# 1s   ÁEc                óú   € T pVP                  R4      pW"^,
          ,          V^,
          ,          ^,          p\        V4       F4  w  rEVR8X  d    W2V^,
          ,          ^,          ,          pK+  V^,          pK6  	  V# )zV
Compute number of triangles in the threshold graph with the
given creation sequence.
r   r   )r0   r   )r$   r"   ÚdrÚntrir   Útyps   &     r   Ú	trianglesri   ¸  sm   € ð 
€BØ	�‰�#‹€BØ�a•�=˜B �FÕ# aÕ'€Dô ˜B–-‰ˆØ�#Œ:Ø˜"˜q�&•M AÕ%Õ%ŠDà�!�GŠBñ	  ð
 €Kr5   c                ó   € T p. pVP                  R4      pV^,
          V^,
          ,          ^,          p^ p^ p\        V4       F‡  w  rxVR8X  d!   V^,          pWC^,
          V,          ,           p	MHX
R8X  d#   WC^,
          V,          ,          p^ pW6,          p^ pV^,          pW3^,
          ,          ^,          p	VP                  V	4       Tp
K‰  	  V# )zL
Return triangle sequence for the given threshold graph creation sequence.

r   ©r0   r   r,   )r$   r"   Úseqrf   ÚdcurÚirunÚdrunr   ÚsymÚtriÚprevsyms   &          r   Útriangle_sequencers   Ì  sÄ   € ð
 
€BØ
€CØ	�‰�#‹€BØ��F�r˜A•vÕ !Õ#€DØ€DØ€DÜ˜B–-‰ˆØ�#Œ:Ø�A�IˆDØ˜q�& D�Õ(‰Cà˜#Œ~Ø˜a� 4�Õ'�Ø�Ø•
�Ø�Ø�A�IˆDØ˜Q�•- 1Õ$ˆCØ�
‰
�3ŒØŠñ  ð €Jr5   c                óü   € \        V 4      p\        V 4      p. p\        V4       FT  w  rEW,          pV^8:  d   VP                  ^ 4       K'  WU^,
          ,          ^,          pVP                  Wg,          4       KV  	  V# )zJ
Return cluster sequence for the given threshold graph creation sequence.
)rs   r   r   r,   )r$   ÚtriseqÚdegseqÚcseqr   Údegrq   Úmax_sizes   &       r   Úcluster_sequencerz   è  sq   € ô Ð0Ó1€FÜÐ.Ó/€FØ€DÜ˜FÖ#‰ˆØ�iˆØ�!Œ8Ø�K‰K˜ŒNÙØ �7•O¨Õ)ˆØ�‰�C•NÖ#ñ $ð €Kr5   c                óÌ   € T p. pVP                  R4      p\        V4       F?  w  rEVR8X  d#   V^,          pVP                  W4,           4       K.  VP                  V4       KA  	  V# )zQ
Return degree sequence for the threshold graph with the given
creation sequence
r   rk   )r$   r"   rl   Úrdr   rp   s   &     r   r   r   ù  s[   € ð
 
€BØ
€CØ	�‰�#‹€BÜ˜B–-‰ˆØ�#Œ:Ø�!�GˆBØ�J‰J�r•vÖà�J‰J�rŽNñ  ð €Jr5   c                ór   € \        V 4      p\        \        V 4      4      pW^,
          ,          pW#,          pV# )zu
Return the density of the graph with this creation_sequence.
The density is the fraction of possible edges present.
)r   Úsumr   )r$   ÚNÚtwo_sizeÚtwo_possibleÚdens   &    r   Údensityrƒ   
  s7   € ô
 	ÐÓ€AÜ”?Ð#4Ó5Ó6€HØ˜A�•;€LØ
Õ
!€CØ€Jr5   c                óz  € T p^ p^ p^ p^ pVP                  R4      p\        V4       UUu. uF  w  rxVR8X  g   K  VNK  	  p	pp\        V4      p
\        V4       Fz  w  rxVR8X  d   V	P                  ^ 4       W§,          pV	 FO  pW¬,          pW-V,          ,          pW;^,          V^,          ,           ,          pWKV,           ,          pV^,          pKQ  	  K|  	  ^V,          V,          WD,          ,
          p^V,          V,          WD,          ,
          pV^ 8X  d   V^ 8X  d   ^# \	        RV 24      hWþ,          # u uppi )z6
Return the degree-degree correlation over all edges.
r   z"Zero Denominator but Numerator is )r0   r   r   r   r   )r$   r"   Ús1Ús2Ús3Úmr|   r   rp   Úrdir   ÚdegiÚdjÚdegjÚdenomÚnumers   &               r   Údegree_correlationr�     s!  € ð 
€BØ	
€BØ	
€BØ	
€BØ	€AØ	�‰�#‹€BÜ$ Rœ=Ô
7™=‘�¨C°3©J�1ˆ1™=€CÑ
7Ü	˜Ó	€BÜ˜B–-‰ˆØ�#Œ:Ø�G‰G�AŒJØ�uˆÛˆBØ•6ˆDØ˜•+ÕˆBØ˜•'˜D !�GÕ#Õ#ˆBØ˜•+ÕˆBØ��FŠAó ñ	  ð ��E�B�J˜�Õ €EØ��E�B�J˜�Õ €EØ�„zØ�AŒ:ÙÜÐ=¸e¸WÐEÓFÐFØ�=Ðùó% 8s
   ªD7ºD7c                ó0  € V ^ ,          p\        V\        4      '       d,   \        \        V 4      4       Uu. uF  qDW,          3NK  	  ppMw\        V\        4      '       d   V R,          pMW\        V\
        4      '       d7   \        V 4      p\        \        V4      4       Uu. uF  qDWd,          3NK  	  ppM\        R4      hV Uu. uF  qw^ ,          NK  	  ppW(9  d   \        RV R24      hW9  d   \        RV R24      hW8X  d   V.# VP                  V4      p	VP                  V4      p
\        Wš4      pW[,          ^,          R8X  d   W.# W[R pV'       d,   VP                  4       pV^,          R8X  g   K(  W^ ,          V.# R# u upi u upi u upi )a  
Find the shortest path between u and v in a
threshold graph G with the given creation_sequence.

For an unlabeled creation_sequence, the vertices
u and v must be integers in (0,len(sequence)) referring
to the position of the desired vertices in the sequence.

For a labeled creation_sequence, u and v are labels of vertices.

Use cs=creation_sequence(degree_sequence,with_labels=True)
to convert a degree sequence to a creation sequence.

Returns a list of vertices from u to v.
Example: if they are neighbors, it returns [u,v]
r   r&   zVertex z$ not in graph from creation_sequencer   Nr   )r   r'   r+   r   r(   r)   r4   r*   r   ÚindexÚmaxr   )r$   rR   r#   r-   r   r"   rP   r.   ÚvertsÚuindexÚvindexÚbigindÚverts   &&&          r   Úshortest_pathr˜   5  sx  € ð$ ˜aÕ €EÜ�%œ×ÒÜ16´sÐ;LÓ7MÔ1NÓOÑ1N¨AÐ#Õ&Ó'Ñ1NˆÐOˆÜ	�Eœ5×	!Ò	!Ø˜qÕ!‰Ü	�Eœ3×	Ò	ÜÐ(Ó)ˆÜ"'¬¨B«¤.Ó1¡.˜Q�"•%‹j¡.ˆÐ1ˆäÐ<Ó=Ð=áÓ™2�aˆq�TˆT™2€EÐØ„~Ü˜7 1 #Ð%IÐJÓKÐKØ„~Ü˜7 1 #Ð%IÐJÓKÐKà„vØˆsˆ
à�[‰[˜‹^€FØ�[‰[˜‹^€FÜ�Ó €FØ	…z�!…}˜ÔØˆvˆà	ˆGˆ€Bß
Ø�v‰v‹xˆØ��7�cŽ>Ø˜A•w �?Ð"à€Iùò= Pùò
 2ùò s   ¶F	Â"FÃFc                óä  € V ^ ,          p\        V\        4      '       d-   \        V \        4      '       d   V R,          pMŽ\        V 4      pM‚\        V\        4      '       d@   V  Uu. uF  qD^,          NK  	  ppV  Uu. uF  qD^ ,          NK  	  upP	                  V4      pM-\        V\
        4      '       d   \        V 4      pM\        R4      h\        V4      p^.V,          p^ Wa&   \        V^,           V4       F  pW7,          R8X  g   K  ^Wg&   K  	  W1,          R8X  d   \        V4       F  p^Wg&   K	  	  \        V^,
          ^ R4       F  pW7,          R8X  d    V# RWg&   K  	  V# u upi u upi )al  
Return the shortest path length from indicated node to
every other node for the threshold graph with the given
creation sequence.
Node is indicated by index i in creation_sequence unless
creation_sequence is labeled in which case, i is taken to
be the label of the node.

Paths lengths in threshold graphs are at most 2.
Length to unreachable nodes is set to -1.
r   r&   r   r   )
r   r'   r7   r(   r‘   r)   r4   r*   r   r+   )r$   r   r-   r"   r#   r   Úsplr<   s   &&      r   Úshortest_path_lengthr›   j  sQ  € ð ˜aÕ €EÜ�%œ×ÒÜÐ'¬×.Ò.Ø" 1Õ%‰BäÐ'Ó(‰BÜ	�Eœ5×	!Ò	!Ù-Ó.Ñ-�q��dˆdÑ-ˆÐ.Ù,Ó-Ñ,�aˆq�TˆTÑ,Ñ-×3Ñ3°AÓ6‰Ü	�Eœ3×	Ò	ÜÐ(Ó)‰äÐ<Ó=Ð=ô 	ˆB‹€AØˆ#��'€CØ€C�Fä�1�q•5˜!Ž_ˆØ�5�CŽ<ØˆC‹Fñ ð 
…u�„|Ü�q–ˆAØˆC‹Fñ ô �1�q•5˜!˜RÖ ˆØ�5�CŒ<Øà€Jð ˆ‹ñ !ð €Jùò/ /ùÚ-s   Á&E(Á=E-c                ó:  € T p. pRp\        VP                  R4      4      p^ p^ pRp\        V4       F˜  w  ršV
R8X  dQ   W†^,
          V,          V,          ,           ^V,          W—,
          V,
          ,          V,          ,           pV^,          pM VR8X  d   XpWW,          p^ p^ p^ pV^,          pVP                  \        V4      4       T
pKš  	  V'       dA   \	        V4      pRV^,
          V^,
          ,          ,          pV Uu. uF  qîV,          NK  	  ppV# u upi )z©
Return betweenness for the threshold graph with the given creation
sequence.  The result is unscaled.  To scale the values
to the interval [0,1] divide by (n-1)*(n-2).
r   g        ç      ð?)Úfloatr0   r   r,   r   )r$   Ú
normalizedr"   rl   Úlastcharrf   rn   ro   Údlastr   ÚcÚbr^   Úscaler.   s   &&             r   Úbetweenness_sequencer¥   ˜  s  € ð 
€BØ
€CØ€HÜ	ˆr�x‰x˜‹}Ó	€BØ€DØ€DØ€EÜ˜"–‰ˆØ�Œ8ð  � TÕ)¨BÕ.Õ.°°Tµ¸Q½XÈ½_Õ1MÐPRÕ1RÕRˆAØ�A�I‰Dà˜3ŒØ�Ø•
�Ø�Ø�ØˆAØ�A�IˆDØ�
‰
”5˜“8ÔØŠñ! ÷& Ü�B“ˆØ˜ �	 e¨a¥iÕ0Õ1ˆÙ"%Ó&¡#˜Q�5�yˆy¡#ˆÐ&à€Jùò 's   ÄDc                óx  € \        V 4      p\        V4      p^ .V,          pVR,          p\        VR,          4      pV^ ,          pR\        V4      ,          .V,          V^ &   ^ V^ &   TpWV,          pRp^p	^p
W¦8  dn   R\        Wª,          V	,           4      ,          pW›) .,          W«,          .,           ^ .W),
          ^,
          ,          ,           W9&   WtV	&   V	^,          p	V
^,          p
Ks  \        V4      ^8X  d   WC3# VR,           EF.  pR\        Wi,          W–,           ,          4      ,          pW–) V,          .,          WiV,          .,          ,           ^ .W),
          V,
          ,          ,           W9&   V'       * pV'       d   W•,           pWV,          pMTpWtV	&   T	pV	^,          p	^p
W¦8  g   K¨  R\        Wœ,
          Wª,          ,           4      ,          p^ .V,          Wœ,
          V) .,          ,           W«,          .,           ^ .W),
          ^,
          ,          ,           W9&   WtV	&   V	^,          p	V
^,          p
K‘  	  WC3# )aº  
Return a 2-tuple of Laplacian eigenvalues and eigenvectors
for the threshold network with creation_sequence.
The first value is a list of eigenvalues.
The second value is a list of eigenvectors.
The lists are in the same order so corresponding eigenvectors
and eigenvalues are in the same position in the two lists.

Notice that the order of the eigenvalues returned by eigenvalues(cs)
may not correspond to the order of these eigenvectors.
r   :NNé   r�   T:é   NN)r   r~   r   r   )r$   r/   r   ÚvecÚvalrf   ÚnnÚeÚtype_dr   Úddr¤   Ústs   &            r   Úeigenvectorsr°   À  sö  € ô Ð(Ó
)€CÜˆC‹€AØˆ#��'€CØ
ˆa�&€Cä	ˆS��X‹€Bà	ˆQ�€BØ”D˜“G�mˆ_˜qÕ €Cˆ�FØ€Cˆ�FØ
€AØ…H€BØ€FØ	€AØ	
€BØ
Œ'Ø”d˜2�7 Q�;Ó'Õ'ˆØ�f�X• ¥ Õ,°¨s°aµe¸aµiÕ/@Õ@ˆ‰ØˆA‰Ø	ˆQ�ˆØ
ˆa�ŠÜ
ˆ3ƒx�1„}ØˆzÐØ�"�g‰gˆØ”d˜2�6 Q¥VÕ,Ó-Õ-ˆØ�c˜E•k�]Õ" R¨u­9¨+Õ%5Õ5¸¸¸q½uÀr½zÕ8JÕJˆ‰à”ˆßØ•ˆAØ�H‰BàˆAØˆA‰ØˆØ	ˆQ�ˆØˆØŽgØœ$˜q�v¨­Õ/Ó0Õ0ˆEØ�S˜2•X ¥¨U¨F¨8Õ 3Õ3°rµz°lÕBÀaÀSÈAÍEÐTUÍIÕEVÕVˆC‰FØ�‰FØ��FˆAØ�!�GŠBñ' ð( ˆ:Ðr5   c                ó†   € . pV^,          pV F/  p\        R \        W@4       4       4      pVP                  V4       K1  	  V# )a|  
Returns the coefficients of each eigenvector
in a projection of the vector u onto the normalized
eigenvectors which are contained in eigenpairs.

eigenpairs should be a list of two objects.  The
first is a list of eigenvalues and the second a list
of eigenvectors.  The eigenvectors should be lists.

There's not a lot of error checking on lengths of
arrays, etc. so be careful.
c              3   ó6   "  € T F  w  rW,          x € K  	  R # 5i©N© )Ú.0ÚevvÚuvs   &  r   Ú	<genexpr>Ú&spectral_projection.<locals>.<genexpr>
  s   é € Ð5©*™Y˜c�—’«*ùs   ‚)r~   r_   r,   )rR   Ú
eigenpairsÚcoeffÚevectÚevr¢   s   &&    r   Úspectral_projectionr¾   ú  sB   € ð €EØ�q�M€EÛˆÜÑ5¬#¨b¬*Ó5Ó5ˆØ�‰�QŽñ ð €Lr5   c                ó  € \        V 4      pVP                  4        . p^ p\        V4      pVP                  4       pV'       dJ   WT8  d   VP	                  V4       V^,          pK*  V^,          pV'       d   VP                  4       pKM  ^ pKQ  V# )a¼  
Return sequence of eigenvalues of the Laplacian of the threshold
graph for the given creation_sequence.

Based on the Ferrer's diagram method.  The spectrum is integral
and is the conjugate of the degree sequence.

See::

  @Article{degree-merris-1994,
   author = {Russel Merris},
   title = {Degree maximal graphs are Laplacian integral},
   journal = {Linear Algebra Appl.},
   year = {1994},
   volume = {199},
   pages = {381--389},
  }

)r   r   r   r   r,   )r$   rv   ÚeiglistÚeigÚrowÚbigdegs   &     r   ÚeigenvaluesrÄ     st   € ô( Ð.Ó/€FØ
‡K�K„MØ€GØ
€CÜ
ˆf‹+€CØ�Z‰Z‹\€Fß
ØŒ<Ø�N‰N˜3ÔØ�1�HŠCà�1�HˆCßØŸ™›’à’Ø€Nr5   c                óÜ   € ^ Tu;8:  d   ^8:  g   M \        R4      hR.p\        ^V 4       F<  pVP                  4       V8  d   VP                  R4       K+  VP                  R4       K>  	  V# )aî  
Create a random threshold sequence of size n.
A creation sequence is built by randomly choosing d's with
probability p and i's with probability 1-p.

s=nx.random_threshold_sequence(10,0.5)

returns a threshold sequence of length 10 with equal
probably of an i or a d at each position.

A "random" threshold graph can be built with

G=nx.threshold_graph(s)

seed : integer, random_state, or None (default)
    Indicator of random number generation state.
    See :ref:`Randomness<randomness>`.
zp must be in [0,1]r   r   )r   r+   Úrandomr,   )r
   ÚpÚseedr"   r   s   &&&  r   Úrandom_threshold_sequencerÉ   9  s]   € ð( �ŽK�aŽKÜÐ-Ó.Ð.à
ˆ€BÜ�1�aŽ[ˆØ�;‰;‹=˜1ÔØ�I‰I�cŽNà�I‰I�cŽNñ	 ð
 €Ir5   c                ó   € R.R.V ^,
          ,          ,           pW8  d   RW!&   V# WV ^,
          ,          ^,          8”  d   \        R4      hV ^,
          pV ^,
          pWA8  d   RW#&   V^,          pWC,          pK  WV,
          ,
          pRW#&   V# )aá  
Returns a "right-dominated" threshold sequence with `n` vertices and `m` edges.

Each vertex in the sequence is either dominant or isolated.
In the "right-dominated" version, once the basic sequence is formed,
isolated vertices may be flipped to dominant from the right in order
to reach the target number of edges.

Parameters
----------
n : int
    Number of vertices.
m : int
    Number of edges.

Returns
-------
A list of 'd' (dominant) and 'i' (isolated) forming a right-dominated threshold sequence.

Raises
------
ValueError
    If `m` exceeds the maximum number of edges.

Examples
--------
>>> from networkx.algorithms.threshold import right_d_threshold_sequence
>>> right_d_threshold_sequence(5, 3)
['d', 'i', 'i', 'd', 'i']
r   r   ú#Too many edges for this many nodes.©r   )r
   rˆ   r"   Úindr~   s   &&   r   Úright_d_threshold_sequencerÎ   \  s•   € ð@ ˆ�#�˜!˜a�%•Õ	 €Bð 	„uØˆ‰Øˆ	ð 	��A•�;˜�?ÔÜÐ>Ó?Ð?ð ˆa�%€CØ
ˆa�%€CØ
Œ'Øˆ‰Øˆq�ˆØ�
ŠØ
�S�y�/€CØ€B�GØ€Ir5   c                ó$  € R.R.V ^,
          ,          ,           pW8  d   RW!&   V# WV ^,
          ,          ^,          8”  d   \        R4      hRW ^,
          &   V ^,
          p^pW18  d   RW$&   W4,          pV^,          pK  W18”  d   RW#V,
          &   V# )a¯  
Returns a "left-dominated" threshold sequence with `n` vertices and `m` edges.

Each vertex in the sequence is either dominant or isolated.
In the "left-dominated" version, once the basic sequence is formed,
isolated vertices may be flipped to dominant from the left in order
to reach the target number of edges.

Parameters
----------
n : int
    Number of vertices.
m : int
    Number of edges.

Returns
-------
A list of 'd' (dominant) and 'i' (isolated) forming a left-dominated threshold sequence.

Raises
------
ValueError
    If `m` exceeds the maximum number of edges.

Examples
--------
For certain small cases, both left and right dominated versions produce
the same sequence. However, for larger values of `m`, the difference in
flipping order becomes evident. For instance, compare the sequences for
``n=6, m=8``:

>>> from networkx.algorithms.threshold import left_d_threshold_sequence
>>> seq = left_d_threshold_sequence(6, 8)
>>> seq
['d', 'd', 'd', 'i', 'i', 'd']

In contrast, the right-dominated version yields:

>>> from networkx.algorithms.threshold import right_d_threshold_sequence
>>> right_seq = right_d_threshold_sequence(6, 8)
>>> right_seq
['d', 'i', 'i', 'd', 'i', 'd']
r   r   rË   rÌ   )r
   rˆ   r"   r~   rÍ   s   &&   r   Úleft_d_threshold_sequencerÐ   “  sš   € ðZ ˆ�#�˜!˜a�%•Õ	 €Bð 	„uØˆ‰Øˆ	ð 	��A•�;˜�?ÔÜÐ>Ó?Ð?ð €Bˆ1…u�IØ
ˆa�%€CØ
€CØ
Œ'Øˆ‰Ø�
ˆØˆq�ŠØ
„wØˆ��7‰Ø€Ir5   )FF)r¨   FFr³   )T)#Ú__doc__Úmathr   ÚnetworkxrH   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r   r$   r   r4   r?   rD   rS   rZ   r   r\   ri   rs   rz   r   rƒ   r�   r˜   r›   r¥   r°   r¾   rÄ   rÉ   rÎ   rÐ   r´   r5   r   Ú<module>r×      s<  ðñõ ã Ý *àÐ!7Ð
8€ð ×Ññ=ó ð=ò>ô.8òv)òXò0+(ô^;ð~ ×Ò˜¨TÔ2ó/ó 3ð/ðd ×Ññó ðð ×Ò Ô%óDó &ðDðD ×Ññó ðò@ò(ò8ò"ò"	òò>2òj+ô\%òP7òtò*$ñT �Óóó ðòD4ônBr5   