+
    �°³jA  ã                   ó  € R t ^ RItRR.t]P                  P                  R4      ]P                  ! RR7      R
R l4       4       t]P                  P                  R4      ]P                  ! RR7      RR l4       4       tR	 t	R# )a  This module provides the functions for node classification problem.

The functions in this module are not imported
into the top level `networkx` namespace.
You can access these functions by importing
the `networkx.algorithms.node_classification` modules,
then accessing the functions as attributes of `node_classification`.
For example:

  >>> from networkx.algorithms import node_classification
  >>> G = nx.path_graph(4)
  >>> G.edges()
  EdgeView([(0, 1), (1, 2), (2, 3)])
  >>> G.nodes[0]["label"] = "A"
  >>> G.nodes[3]["label"] = "B"
  >>> node_classification.harmonic_function(G)
  ['A', 'A', 'B', 'B']

References
----------
Zhu, X., Ghahramani, Z., & Lafferty, J. (2003, August).
Semi-supervised learning using gaussian fields and harmonic functions.
In ICML (Vol. 3, pp. 912-919).
NÚharmonic_functionÚlocal_and_global_consistencyÚdirectedÚ
label_name)Ú
node_attrsc                óæ  € ^ RI p^ RIp\        P                  ! V 4      p\	        W4      w  rgVP
                  ^ ,          ^ 8X  d   \        P                  ! RV R24      hVP
                  ^ ,          pVP
                  ^ ,          p	VP                  W‰34      p
VP                  ^ R7      p^W»^ 8H  &   VP                  P                  RV,          ^ 3Wˆ3R7      P                  4       pWÅ,          P                  4       p^ WÖR,          &   VP                  W‰34      p^WæR,          VR,          3&   \        V4       F  pWÚ,          V,           p
K  	  WsP                  V
^R7      ,          P                  4       # )	aü  Node classification by Harmonic function

Function for computing Harmonic function algorithm by Zhu et al.

Parameters
----------
G : NetworkX Graph
max_iter : int
    maximum number of iterations allowed
label_name : string
    name of target labels to predict

Returns
-------
predicted : list
    List of length ``len(G)`` with the predicted labels for each node.

Raises
------
NetworkXError
    If no nodes in `G` have attribute `label_name`.

Examples
--------
>>> from networkx.algorithms import node_classification
>>> G = nx.path_graph(4)
>>> G.nodes[0]["label"] = "A"
>>> G.nodes[3]["label"] = "B"
>>> G.nodes(data=True)
NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}})
>>> G.edges()
EdgeView([(0, 1), (1, 2), (2, 3)])
>>> predicted = node_classification.harmonic_function(G)
>>> predicted
['A', 'A', 'B', 'B']

References
----------
Zhu, X., Ghahramani, Z., & Lafferty, J. (2003, August).
Semi-supervised learning using gaussian fields and harmonic functions.
In ICML (Vol. 3, pp. 912-919).
Nú*No node on the input graph is labeled by 'ú'.©Úaxisç      ð?©Úshape©ºNNNé    ©r   é   )ÚnumpyÚscipyÚnxÚto_scipy_sparse_arrayÚ_get_label_infor   ÚNetworkXErrorÚzerosÚsumÚsparseÚ	dia_arrayÚtocsrÚtolilÚrangeÚargmaxÚtolist)ÚGÚmax_iterr   ÚnpÚspÚXÚlabelsÚ
label_dictÚ	n_samplesÚ	n_classesÚFÚdegreesÚDÚPÚBÚ_s   &&&             Úh/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/node_classification.pyr   r      sJ  € óZ Ûä
× Ò  Ó#€AÜ(¨Ó7Ñ€Fà‡|�|�A…˜!ÔÜ×ÒØ8¸¸ÀBÐGó
ð 	
ð —‘˜•
€IØ× Ñ  Õ#€IØ
�‰�)Ð'Ó(€Að �e‰e˜ˆe‹m€GØ€G�q‰LÑØ
�	‰	×Ñ˜S 7�]¨AÐ.°yÐ6LÐÓM×SÑSÓU€AØ	
��‰‹€AØ€AˆT…l�Oà
�‰�)Ð'Ó(€AØ$%€AˆT…l�F˜4•LÐ Ñ!ä�8Ž_ˆØ�U�a�KŠñ ð —i‘i ¨�iÓ*Õ+×2Ñ2Ó4Ð4ó    c                óü  € ^ RI p^ RIp\        P                  ! V 4      p\	        W4      w  rxVP
                  ^ ,          ^ 8X  d   \        P                  ! RV R24      hVP
                  ^ ,          p	VP
                  ^ ,          p
VP                  Wš34      pVP                  ^ R7      p^WÌ^ 8H  &   VP                  P                  RVP                  V4      ,          ^ 3W™3R7      P                  4       pWV,          V,          ,          pVP                  Wš34      p^V,
          W÷R,          VR,          3&   \        V4       F  pWë,          V,           pK  	  W„P                  V^R7      ,          P                  4       # )	u[  Node classification by Local and Global Consistency

Function for computing Local and global consistency algorithm by Zhou et al.

Parameters
----------
G : NetworkX Graph
alpha : float
    Clamping factor
max_iter : int
    Maximum number of iterations allowed
label_name : string
    Name of target labels to predict

Returns
-------
predicted : list
    List of length ``len(G)`` with the predicted labels for each node.

Raises
------
NetworkXError
    If no nodes in `G` have attribute `label_name`.

Examples
--------
>>> from networkx.algorithms import node_classification
>>> G = nx.path_graph(4)
>>> G.nodes[0]["label"] = "A"
>>> G.nodes[3]["label"] = "B"
>>> G.nodes(data=True)
NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}})
>>> G.edges()
EdgeView([(0, 1), (1, 2), (2, 3)])
>>> predicted = node_classification.local_and_global_consistency(G)
>>> predicted
['A', 'A', 'B', 'B']

References
----------
Zhou, D., Bousquet, O., Lal, T. N., Weston, J., & SchÃ¶lkopf, B. (2004).
Learning with local and global consistency.
Advances in neural information processing systems, 16(16), 321-328.
Nr   r	   r
   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   Úsqrtr   r    r!   r"   )r#   Úalphar$   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   ÚD2r/   r0   r1   s   &&&&             r2   r   r   k   sX  € ó^ Ûä
× Ò  Ó#€AÜ(¨Ó7Ñ€Fà‡|�|�A…˜!ÔÜ×ÒØ8¸¸ÀBÐGó
ð 	
ð —‘˜•
€IØ× Ñ  Õ#€IØ
�‰�)Ð'Ó(€Að �e‰e˜ˆe‹m€GØ€G�q‰LÑØ	�‰×	Ñ	Ø	ˆr�w‰w�wÓÕ	 Ð#¨IÐ+Að 
ó 
ç�eƒgð ð 	�q•&˜B•Õ€Aà
�‰�)Ð'Ó(€AØ$%¨¥I€AˆT…l�F˜4•LÐ Ñ!ä�8Ž_ˆØ�U�a�KŠñ ð —i‘i ¨�iÓ*Õ+×2Ñ2Ó4Ð4r3   c                ó¦  € ^ RI p. p/ p^ p\        V P                  RR7      4       FP  w  rgW^,          9   g   K  V^,          V,          pW„9  d   WTV&   V^,          pVP                  WdV,          .4       KR  	  VP	                  V4      pTP	                  \        VP                  4       R R7       UU	u. uF  w  r‰VNK	  	  up	p4      p
W:3# u up	pi )a�  Get and return information of labels from the input graph

Parameters
----------
G : Network X graph
label_name : string
    Name of the target label

Returns
-------
labels : numpy array, shape = [n_labeled_samples, 2]
    Array of pairs of labeled node ID and label ID
label_dict : numpy array, shape = [n_classes]
    Array of labels
    i-th element contains the label corresponding label ID `i`
NT)Údatac                 ó   € V ^,          # )r   © )Úxs   &r2   Ú<lambda>Ú!_get_label_info.<locals>.<lambda>Ù   s   € ÈÈ1Îr3   )Úkey)r   Ú	enumerateÚnodesÚappendÚarrayÚsortedÚitems)r#   r   r%   r(   Úlabel_to_idÚlidÚiÚnÚlabelr1   r)   s   &&         r2   r   r   º   sÊ   € ó" à€FØ€KØ
€CÜ˜!Ÿ'™' t˜'Ó,Ö-‰ˆØ˜1�ÖØ�a•D˜Õ$ˆEØÔ'Ø%(˜EÑ"Ø�q•�Ø�M‰M˜1¨%Õ0Ð1Ö2ñ .ð �X‰X�fÓ€FØ—‘Ü% k×&7Ñ&7Ó&9¹~ÕNÔOÑN‘8�5‹ÑNÒOó€Jð ÐÐùó 	Ps   Â5C
)é   rJ   )g®Gáz®ï?rK   rJ   )
Ú__doc__Únetworkxr   Ú__all__ÚutilsÚnot_implemented_forÚ_dispatchabler   r   r   r;   r3   r2   Ú<module>rR      s‘   ðñó2 àÐ >Ð
?€ð ‡�×Ñ˜jÓ)Ø×Ò˜\Ô*óG5ó +ó *ðG5ðT ‡�×Ñ˜jÓ)Ø×Ò˜\Ô*óJ5ó +ó *ðJ5ôZ! r3   