+
    �°³jë%  ã                   óì   € ^ RI Ht ^ RIt^ RIHtHt RR.t]! R4      ]P                  ! RRR	7      RR
 l4       4       t	R t
R tR tR]R]
/t]! R4      ]P                  ! RRR7      RR l4       4       tR# )é    )ÚchainN)Únot_implemented_forÚpairwiseÚmetric_closureÚsteiner_treeÚdirectedÚweightT)Ú
edge_attrsÚreturns_graphc           	     ó2  € ^ RI pVP                  R\        ^R7       \        P                  ! 4       p\        V 4      p\        P                  ! WR7      p\        V4      w  pw  rx\        V 4      \        V4      8w  d   Rp	\        P                  ! V	4      hVP                  V4       V F#  p
VP                  WjWz,          WŠ,          R7       K%  	  V FB  w  pw  rxVP                  V4       V F#  p
VP                  WjWz,          WŠ,          R7       K%  	  KD  	  V# )aÏ  Return the metric closure of a graph.

The metric closure of a graph *G* is the complete graph in which each edge
is weighted by the shortest path distance between the nodes in *G* .

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

Returns
-------
NetworkX graph
    Metric closure of the graph `G`.

Notes
-----
.. deprecated:: 3.6
   `metric_closure` is deprecated and will be removed in NetworkX 3.8.
   Use :func:`networkx.all_pairs_shortest_path_length` instead.

Nzpmetric_closure is deprecated and will be removed in NetworkX 3.8.
Use nx.all_pairs_shortest_path_length instead.)ÚcategoryÚ
stacklevel©r	   z:G is not a connected graph. metric_closure is not defined.©ÚdistanceÚpath)ÚwarningsÚwarnÚDeprecationWarningÚnxÚGraphÚsetÚall_pairs_dijkstraÚnextÚlenÚNetworkXErrorÚremoveÚadd_edge)ÚGr	   r   ÚMÚGnodesÚall_paths_iterÚur   r   ÚmsgÚvs   &&         Ún/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/approximation/steinertree.pyr   r   	   sö   € ó0 à‡M�Mð	9ä#Øð	 ô ô 	�Š‹
€Aä�‹V€Fô ×*Ò*¨1Ô<€NÜ˜~Ó.Ñ€AÑˆÜ
ˆ1ƒv”�X“ÔØJˆÜ×Ò˜sÓ#Ð#Ø
‡M�M�!ÔÛˆØ	�
‰
�1 (¥+°DµGˆ
Ö<ñ ó  .ÑˆÑˆHØ�‰�aÔÛˆAØ�J‰J�q h¥k¸½ˆJÖ@ó ñ  .ð
 €Hó    c           
      óŠ  a a€ \         P                  ! S VSR 7      w  r4/ p/ pS P                  4        F&  pWG,          ^ ,          Wg&   W7,          WWWg,          3&   K(  	  \         P                  ! 4       pS P	                  RR7       F¤  w  r—p
Wi,          Wg,          rËWYV3,          V
P                  S^4      ,           WWV3,          ,           pVP                  W¼4      '       g   VP                  W¼VR7       Kq  \        WØV,          V,          R,          4      pVP                  W¼VR7       K¦  	  \         P                  ! VRRR7      p\         P                  ! 4       pV Ff  w  r—p\         P                  ! S W—SR 7      p\        V4       F8  w  ppVP                  VVS V,          V,          P                  S^4      R 7       K:  	  Kh  	  \        \         P                  ! VRSR7      4      pS P                  4       '       d   V V3R lV 4       pS P                  V4      P                  4       p\!        VV4       VP	                  4       # )r   T)Údata)Ú	weight_d1r*   )r)   r	   Fc           
   3   óx   <aa"  € T F-  w  ooSS\        SS,          S,          VVVV3R  lR7      3x € K/  	  R# 5i)c                 óR   <€ SS,          S,          V ,          P                  S^4      # ©é   ©Úget©Úkr   r#   r%   r	   s   &€€€€r&   Ú<lambda>Ú2_mehlhorn_steiner_tree.<locals>.<genexpr>.<lambda>a   ó   ø€ ¨a°­d°1­g°a­j¯n©n¸VÀQÔ.Gr'   ©ÚkeyN©Úmin©Ú.0r#   r%   r   r	   s   &@@€€r&   Ú	<genexpr>Ú)_mehlhorn_steiner_tree.<locals>.<genexpr>`   s3   úé € ð 
á‘��1ð �”3�q˜•t˜A•w×$GÔHÕIÛùó   …5:)r   Úmulti_source_dijkstraÚnodesr   Úedgesr0   Úhas_edger   r9   Úminimum_spanning_edgesÚshortest_pathr   ÚlistÚis_multigraphÚedge_subgraphÚcopyÚ_remove_nonterminal_leaves)r   Úterminal_nodesr	   Ú	distancesÚpathsÚd_1Úsr%   Ú	G_1_primer#   r)   ÚsuÚsvÚweight_hereÚ
new_weightÚG_2ÚG_3Ú_r   Ún1Ún2ÚG_3_mstÚG_4s   f&f                    r&   Ú_mehlhorn_steiner_treer[   A   sÖ  ù€ Ü×/Ò/°°>È&ÔQÑ€Ià
€CØ
€AØ�W‰WŽYˆØ�x˜�{ˆ‰Ø"�ˆ�•ˆI‹ñ ô
 —’“
€Ià—g‘g 4�gÖ(‰
ˆˆdØ•�q•tˆBØ˜b˜'•l T§X¡X¨f°aÓ%8Õ8¸3À2¸w½<ÕGˆØ×!Ñ! "×)Ò)Ø×Ñ˜r°ÐÖ=ä˜[°B­-¸Õ*;¸KÕ*HÓIˆJØ×Ñ˜r°ÐÖ<ñ )ô ×
#Ò
# I°DÀÔ
M€Cä
�(Š(‹*€CÛ‰ˆˆaÜ×Ò  1°Ô7ˆÜ˜t–n‰FˆB�Ø�L‰L˜˜R¨¨"­¨b­	¯©°f¸aÓ(@ˆLÖAó %ñ ô
 ”2×,Ò,¨S°uÀVÔLÓM€GØ‡�×Òõ
áó
ˆð �/‰/˜'Ó
"×
'Ñ
'Ó
)€CÜ˜s NÔ3Ø�9‰9‹;Ðr'   c           	      ó¢  a a€ \         P                  ! 4       p\        V4      pVP                  4       p\         P                  ! S VSR 7      w  rg\        S 4      \        V4      8w  d   Rp\         P                  ! V4      hV F#  p	VP                  WYWi,          Wy,          R7       K%  	  VP                  4        FX  p\         P                  ! S VSR 7      w  rgVP                  V4       V F#  p	VP                  WYWi,          Wy,          R7       K%  	  KZ  	  \         P                  ! VRRR7      p
\        P                  ! R V
 4       4      pS P                  4       '       d   V V3R lV 4       pS P                  V4      p\         P                  ! VRR	R7      pS P                  V4      P                  4       p\        Wá4       VP!                  4       # )
)Úsourcer	   zG is not a connected graph.r   r   T)r	   r)   c              3   óL   "  € T F  w  rp\        VR ,          4      x € K  	  R# 5i)r   N)r   )r;   r#   r%   Úds   &   r&   r<   Ú$_kou_steiner_tree.<locals>.<genexpr>ƒ   s    é € Ð'UÉ9ÁÀÀa¬°°6µ×(;Ð(;Ë9ùs   ‚"$c           
   3   óx   <aa"  € T F-  w  ooSS\        SS,          S,          VVVV3R  lR7      3x € K/  	  R# 5i)c                 óR   <€ SS,          S,          V ,          P                  S^4      # r-   r/   r1   s   &€€€€r&   r3   Ú-_kou_steiner_tree.<locals>.<genexpr>.<lambda>†   r5   r'   r6   Nr8   r:   s   &@@€€r&   r<   r`   …   s3   úé € ð 
á%‘��1ð �”3�q˜•t˜A•w×$GÔHÕIÛ%ùr>   r	   F)r   r   r   ÚpopÚsingle_source_dijkstrar   r   r   rH   r   rC   r   Úfrom_iterablerF   rG   rI   rA   )r   rJ   r	   ÚHÚunvisited_terminalsr#   rK   rL   r$   r%   Ú	mst_edgesÚmst_all_edgesÚG_SÚT_SÚT_Hs   f&f            r&   Ú_kou_steiner_treern   i   s}  ù€ ô 	�Š‹
€AÜ˜nÓ-Ðð 	×ÑÓ!€AÜ×0Ò0°¸1ÀVÔLÑ€IÜ
ˆ1ƒv”�Y“ÔØ+ˆÜ×Ò˜sÓ#Ð#Û ˆØ	�
‰
�1 )¥,°UµXˆ
Ö>ñ !ð !×%Ñ%Ö'ˆÜ×4Ò4°Q¸qÈÔPÑˆ	Ø×"Ñ" 1Ô%Û$ˆAØ�J‰J�q i¥l¸½ˆJÖBó %ñ (ô ×)Ò)¨!°JÀTÔJ€Iô ×'Ò'Ñ'UÉ9Ó'UÓU€MØ‡�×Òõ
á%ó
ˆð �/‰/˜-Ó
(€CÜ
×
#Ò
# C°¸uÔ
E€Cð �/‰/˜#Ó
×
#Ñ
#Ó
%€CÜ˜sÔ3à�9‰9‹;Ðr'   c           	      óÎ  a € \        V4      pS  Uu0 uF/  p\        \        S V,          4      V0,
          4      ^8X  g   K-  VkK1  	  ppWB,
          pV'       d„   \         P                  ! V 3R lV 4       !  pWeV,          ,          pS P                  V4       V Uu0 uF/  p\        \        S V,          4      V0,
          4      ^8X  g   K-  VkK1  	  ppWB,
          pK‹  R# u upi u upi )r.   c              3   óH   <"  € T F  p\        SV,          4      x € K  	  R # 5i©N)r   )r;   Únr   s   & €r&   r<   Ú-_remove_nonterminal_leaves.<locals>.<genexpr>ž   s   øé € Ð&MÑ:L°Q¤s¨1¨Q­4§y yÓ:Lùs   ƒ"N)r   r   ÚunionÚremove_nodes_from)r   Ú	terminalsÚterminal_setrr   ÚleavesÚnonterminal_leavesÚcandidate_leavess   f&     r&   rI   rI   •   sÈ   ø€ Ü�y“>€LÙÓ8™�Aœc¤# a¨¥d£)¨q¨c¥/Ó2°aÑ7�aˆa™€FÐ8ØÕ.Ðç
ô Ÿ9š9Ô&MÑ:LÓ&MÑNÐØ°Õ=Õ=Ðà	×ÑÐ.Ô/á-ÓKÑ-˜´´S¸¸1½³YÀ!Àµ_Ó1EÈÑ1J—!�!Ñ-ˆÐKØ#Õ2Òñ ùò 9ùò Ls   ‘*CÁ CÂ*C"Ã	C"ÚkouÚmehlhorn)Úpreserve_all_attrsr   c                óò   a a€ Vf   Rp \         V,          pT! S TS4      pS P                  4       '       d   T T3R lT 4       pS P	                  T4      pT#   \         d   p\        T R24      ThRp?ii ; i)um  Return an approximation to the minimum Steiner tree of a graph.

The minimum Steiner tree of `G` w.r.t a set of `terminal_nodes` (also *S*)
is a tree within `G` that spans those nodes and has minimum size (sum of
edge weights) among all such trees.

The approximation algorithm is specified with the `method` keyword
argument. All available algorithms produce a tree whose weight is
within a ``(2 - (2 / l))`` factor of the weight of the optimal Steiner tree,
where ``l`` is the minimum number of leaf nodes across all possible Steiner
trees.

* ``"kou"`` [2]_ (runtime $O(|S| |V|^2)$) computes the minimum spanning tree of
  the subgraph of the metric closure of *G* induced by the terminal nodes,
  where the metric closure of *G* is the complete graph in which each edge is
  weighted by the shortest path distance between the nodes in *G*.

* ``"mehlhorn"`` [3]_ (runtime $O(|E|+|V|\log|V|)$) modifies Kou et al.'s
  algorithm, beginning by finding the closest terminal node for each
  non-terminal. This data is used to create a complete graph containing only
  the terminal nodes, in which edge is weighted with the shortest path
  distance between them. The algorithm then proceeds in the same way as Kou
  et al..

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

terminal_nodes : list
     A list of terminal nodes for which minimum steiner tree is
     to be found.

weight : string (default = 'weight')
    Use the edge attribute specified by this string as the edge weight.
    Any edge attribute not present defaults to 1.

method : string, optional (default = 'mehlhorn')
    The algorithm to use to approximate the Steiner tree.
    Supported options: 'kou', 'mehlhorn'.
    Other inputs produce a ValueError.

Returns
-------
NetworkX graph
    Approximation to the minimum steiner tree of `G` induced by
    `terminal_nodes` .

Raises
------
NetworkXNotImplemented
    If `G` is directed.

ValueError
    If the specified `method` is not supported.

NetworkXError
    If ``method=kou`` and `G` is not connected

KeyError
    If ``method=mehlhorn``, `G` is not connected, and there is not at least
    one terminal node in every component.

Notes
-----
For multigraphs, the edge between two nodes with minimum weight is the
edge put into the Steiner tree.

The ``mehlhorn`` method supports graphs with multiple components, so long
as there is at least one terminal node in each component.

References
----------
.. [1] Steiner_tree_problem on Wikipedia.
       https://en.wikipedia.org/wiki/Steiner_tree_problem
.. [2] Kou, L., G. Markowsky, and L. Berman. 1981.
       â€˜A Fast Algorithm for Steiner Treesâ€™.
       Acta Informatica 15 (2): 141â€“45.
       https://doi.org/10.1007/BF00288961.
.. [3] Mehlhorn, Kurt. 1988.
       â€˜A Faster Approximation Algorithm for the Steiner Problem in Graphsâ€™.
       Information Processing Letters 27 (3): 125â€“28.
       https://doi.org/10.1016/0020-0190(88)90066-X.
Nr|   z( is not a valid choice for an algorithm.c           
   3   óx   <aa"  € T F-  w  ooSS\        SS,          S,          VVVV3R  lR7      3x € K/  	  R# 5i)c                 ó@   <€ SS,          S,          V ,          S,          # rq   © r1   s   &€€€€r&   r3   Ú(steiner_tree.<locals>.<genexpr>.<lambda>  s   ø€ ¨a°­d°1­g°a­j¸Ö.@r'   r6   Nr8   r:   s   &@@€€r&   r<   Ústeiner_tree.<locals>.<genexpr>  s/   úé € ð 
ÙOTÁtÀqÈ!ˆQ�”3�q˜•t˜A•w×$@ÔAÕBËuùr>   )Ú
ALGORITHMSÚKeyErrorÚ
ValueErrorrF   rG   )r   rJ   r	   ÚmethodÚalgoÚerA   ÚTs   f&f&    r&   r   r   ­   s‹   ù€ ðl ‚~ØˆðUÜ˜&Õ!ˆñ ��N FÓ+€Eà‡�×Òõ
ÙOTó
ˆð 	
�‰˜Ó€AØ€Høô ô UÜ˜F˜8Ð#KÐLÓMÐSTÐTûðUús   ŠA ÁA6Á"A1Á1A6r   )r	   N)Ú	itertoolsr   Únetworkxr   Únetworkx.utilsr   r   Ú__all__Ú_dispatchabler   r[   rn   rI   r„   r   r�   r'   r&   Ú<module>r�      s�   ðÝ ã ß 8à˜^Ð
,€ñ �ZÓ Ø×Ò˜X°TÔ:ó3ó ;ó !ð3òl%òP)òX3ð& 
ÐØÐ&ð€
ñ �ZÓ Ø×Ò T¸Ô>ócó ?ó !òcr'   