ó
    …~if  ã                   óš   • S r SSKrSSKJr  SSKJr  SS/r\" S	5      \R                  " S
S9SS j5       5       r	\R                  S 5       r
g)a  Functions for finding node and edge dominating sets.

A `dominating set`_ for an undirected graph *G* with vertex set *V*
and edge set *E* is a subset *D* of *V* such that every vertex not in
*D* is adjacent to at least one member of *D*. An `edge dominating set`_
is a subset *F* of *E* such that every edge not in *F* is
incident to an endpoint of at least one edge in *F*.

.. _dominating set: https://en.wikipedia.org/wiki/Dominating_set
.. _edge dominating set: https://en.wikipedia.org/wiki/Edge_dominating_set

é    Né   )Únot_implemented_foré   )Úmaximal_matchingÚmin_weighted_dominating_setÚmin_edge_dominating_setÚdirectedÚweight)Ú
node_attrsc           	      óH  ^ ^^• [        T 5      S:X  a
  [        5       $ [        5       mU UU4S jn[        T 5      nT  Vs0 s H  oDU1[        T U   5      -  _M     nnU(       a:  [        UR                  5       US9u  pgTR	                  U5        XV	 X7-  nU(       a  M:  T$ s  snf )a·  Returns a dominating set that approximates the minimum weight node
dominating set.

Parameters
----------
G : NetworkX graph
    Undirected graph.

weight : string
    The node attribute storing the weight of an node. If provided,
    the node attribute with this key must be a number for each
    node. If not provided, each node is assumed to have weight one.

Returns
-------
min_weight_dominating_set : set
    A set of nodes, the sum of whose weights is no more than `(\log
    w(V)) w(V^*)`, where `w(V)` denotes the sum of the weights of
    each node in the graph and `w(V^*)` denotes the sum of the
    weights of each node in the minimum weight dominating set.

Examples
--------
>>> G = nx.Graph([(0, 1), (0, 4), (1, 4), (1, 2), (2, 3), (3, 4), (2, 5)])
>>> nx.approximation.min_weighted_dominating_set(G)
{1, 2, 4}

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

Notes
-----
This algorithm computes an approximate minimum weighted dominating
set for the graph `G`. The returned solution has weight `(\log
w(V)) w(V^*)`, where `w(V)` denotes the sum of the weights of each
node in the graph and `w(V^*)` denotes the sum of the weights of
each node in the minimum weight dominating set for the graph.

This implementation of the algorithm runs in $O(m)$ time, where $m$
is the number of edges in the graph.

References
----------
.. [1] Vazirani, Vijay V.
       *Approximation Algorithms*.
       Springer Science & Business Media, 2001.

r   c                 óh   >• U u  pTR                   U   R                  TS5      [        UT-
  5      -  $ )zœReturns the cost-effectiveness of greedily choosing the given
node.

`node_and_neighborhood` is a two-tuple comprising a node and its
closed neighborhood.

é   )ÚnodesÚgetÚlen)Únode_and_neighborhoodÚvÚneighborhoodÚGÚdom_setr
   s      €€€Úm/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/approximation/dominating_set.pyÚ_costÚ*min_weighted_dominating_set.<locals>._costS   s4   ø€ ð 0‰ˆØ�w‰w�q‰z�~‰~˜f aÓ(¬3¨|¸gÑ/EÓ+FÑFÐFó    )Úkey)r   ÚsetÚminÚitemsÚadd)	r   r
   r   Úverticesr   ÚneighborhoodsÚdom_nodeÚmin_setr   s	   ``      @r   r   r      s§   ú€ ôl ˆ1ƒv�ƒ{Ü‹uˆô ‹e€G÷	Gô �1‹v€Hñ 23Ó3²¨A˜˜œc ! A¡$›i™Ò'±€MÐ3ö ô   × 3Ñ 3Ó 5¸5ÑAÑˆð 	�‰�HÔØÐ#ØÑˆ÷ ˆ(ð €Nùò 4s   ¾Bc                 ó<   • U (       d  [        S5      e[        U 5      $ )ar  Returns minimum cardinality edge dominating set.

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

Returns
-------
min_edge_dominating_set : set
  Returns a set of dominating edges whose size is no more than 2 * OPT.

Examples
--------
>>> G = nx.petersen_graph()
>>> nx.approximation.min_edge_dominating_set(G)
{(0, 1), (4, 9), (6, 8), (5, 7), (2, 3)}

Raises
------
ValueError
    If the input graph `G` is empty.

Notes
-----
The algorithm computes an approximate solution to the edge dominating set
problem. The result is no more than 2 * OPT in terms of size of the set.
Runtime of the algorithm is $O(|E|)$.
z"Expected non-empty NetworkX graph!)Ú
ValueErrorr   )r   s    r   r   r   t   s   € ö> ÜÐ=Ó>Ð>Ü˜AÓÐr   )N)Ú__doc__ÚnetworkxÚnxÚutilsr   Úmatchingr   Ú__all__Ú_dispatchabler   r   © r   r   Ú<module>r.      si   ðñó å (Ý 'à(Ð*CÐ
D€ñ �ZÓ Ø×Ò˜XÑ&óXó 'ó !ðXðv ×Ññ ó ñ r   