ó
    …~i%­  ã                   ó®  • S r SSKJrJr  SSKrSSKJr  / SQr\" S5      \" S5      \R                  S 5       5       5       r
S	 r\R                  S
 5       r\R                  S 5       r\R                  S 5       r\" S5      \" S5      \R                  " SS9SS j5       5       5       r\" S5      \" S5      \R                  " SS9SS j5       5       5       rg)z;Functions for computing and verifying matchings in a graph.é    )ÚcombinationsÚrepeatN)Únot_implemented_for)Úis_matchingÚis_maximal_matchingÚis_perfect_matchingÚmax_weight_matchingÚmin_weight_matchingÚmaximal_matchingÚ
multigraphÚdirectedc                 óÒ   • [        5       n[        5       nU R                  5        H>  nUu  pEXB;  d  M  XR;  d  M  XE:w  d  M  UR                  U5        UR                  U5        M@     U$ )aI  Find a maximal matching in the graph.

A matching is a subset of edges in which no node occurs more than once.
A maximal matching cannot add more edges and still be a matching.

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

Returns
-------
matching : set
    A maximal matching of the graph.

Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (2, 3), (2, 4), (3, 5), (4, 5)])
>>> sorted(nx.maximal_matching(G))
[(1, 2), (3, 5)]

Notes
-----
The algorithm greedily selects a maximal matching M of the graph G
(i.e. no superset of M exists). It runs in $O(|E|)$ time.
)ÚsetÚedgesÚaddÚupdate©ÚGÚmatchingÚnodesÚedgeÚuÚvs         ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/algorithms/matching.pyr   r      sW   € ô< ‹u€HÜ‹E€EØ—‘–	ˆð ‰ˆØ�>˜a�n°µØ�L‰L˜ÔØ�L‰L˜Öñ ð €Oó    c                 óÊ   • [        5       nU R                  5        HD  nUu  p4XC4U;   d  X!;   a  M  X4:X  a  [        R                  " SU 35      eUR	                  U5        MF     U$ )a  Converts matching dict format to matching set format

Converts a dictionary representing a matching (as returned by
:func:`max_weight_matching`) to a set representing a matching (as
returned by :func:`maximal_matching`).

In the definition of maximal matching adopted by NetworkX,
self-loops are not allowed, so the provided dictionary is expected
to never have any mapping from a key to itself. However, the
dictionary is expected to have mirrored key/value pairs, for
example, key ``u`` with value ``v`` and key ``v`` with value ``u``.

z%Selfloops cannot appear in matchings )r   ÚitemsÚnxÚNetworkXErrorr   )r   r   r   r   r   s        r   Úmatching_dict_to_setr    <   sc   € ô ‹E€EØ—‘Ö ˆØ‰ˆØˆ6�U‹?˜d›mÙØ‹6Ü×"Ò"Ð%JÈ4È&Ð#QÓRÐRØ�	‰	�$Žñ !ð €Lr   c                 ó‚  • [        U[        5      (       a  [        U5      n[        5       nU H�  n[	        U5      S:w  a  [
        R                  " SU 35      eUu  pEX@;  d  XP;  a  [
        R                  " SU S35      eXE:X  a    gU R                  XE5      (       d    gXB;   d  XR;   a    gUR                  U5        M‘     g)a[  Return True if ``matching`` is a valid matching of ``G``

A *matching* in a graph is a set of edges in which no two distinct
edges share a common endpoint. Each node is incident to at most one
edge in the matching. The edges are said to be independent.

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

matching : dict or set
    A dictionary or set representing a matching. If a dictionary, it
    must have ``matching[u] == v`` and ``matching[v] == u`` for each
    edge ``(u, v)`` in the matching. If a set, it must have elements
    of the form ``(u, v)``, where ``(u, v)`` is an edge in the
    matching.

Returns
-------
bool
    Whether the given set or dictionary represents a valid matching
    in the graph.

Raises
------
NetworkXError
    If the proposed matching has an edge to a node not in G.
    Or if the matching is not a collection of 2-tuple edges.

Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (2, 3), (2, 4), (3, 5), (4, 5)])
>>> nx.is_maximal_matching(G, {1: 3, 2: 4})  # using dict to represent matching
True

>>> nx.is_matching(G, {(1, 3), (2, 4)})  # using set to represent matching
True

é   úmatching has non-2-tuple edge úmatching contains edge ú with node not in GFT©	Ú
isinstanceÚdictr    r   Úlenr   r   Úhas_edger   r   s         r   r   r   U   s´   € ôR �(œD×!Ñ!Ü'¨Ó1ˆä‹E€EÛˆÜˆt‹9˜‹>Ü×"Ò"Ð%CÀDÀ6Ð#JÓKÐKØ‰ˆØ‹:˜›Ü×"Ò"Ð%<¸T¸FÐBUÐ#VÓWÐWØ‹6ÙØ�z‰z˜!×ÑÙØ‹:˜›ÙØ�‰�TÖñ ð r   c                 óB  • [        U[        5      (       a  [        U5      n[        5       n[        5       nU H²  n[	        U5      S:w  a  [
        R                  " SU 35      eUu  pVXP;  d  X`;  a  [
        R                  " SU S35      eXV:X  a    gU R                  XV5      (       d    gXS;   d  Xc;   a    gUR                  U5        UR                  U5        UR                  Xe45        M´     U R                   H#  u  pVXV4U;  d  M  XS;  d  M  Xc;  d  M  XV:w  d  M#    g   g)a  Return True if ``matching`` is a maximal matching of ``G``

A *maximal matching* in a graph is a matching in which adding any
edge would cause the set to no longer be a valid matching.

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

matching : dict or set
    A dictionary or set representing a matching. If a dictionary, it
    must have ``matching[u] == v`` and ``matching[v] == u`` for each
    edge ``(u, v)`` in the matching. If a set, it must have elements
    of the form ``(u, v)``, where ``(u, v)`` is an edge in the
    matching.

Returns
-------
bool
    Whether the given set or dictionary represents a valid maximal
    matching in the graph.

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

r"   r#   r$   r%   FT)r'   r(   r    r   r)   r   r   r*   r   r   r   )r   r   r   r   r   r   r   s          r   r   r   ’   sÿ   € ô> �(œD×!Ñ!Ü'¨Ó1ˆä‹E€EÜ‹E€EÛˆÜˆt‹9˜‹>Ü×"Ò"Ð%CÀDÀ6Ð#JÓKÐKØ‰ˆØ‹:˜›Ü×"Ò"Ð%<¸T¸FÐBUÐ#VÓWÐWØ‹6ÙØ�z‰z˜!×ÑÙØ‹:˜›ÙØ�‰�TÔØ�	‰	�$ŒØ�	‰	�1�&Öñ ð$ —”‰ˆØˆ6˜Õà�~ !¥.°QµVÙñ	 ð
 r   c                 ó®  • [        U[        5      (       a  [        U5      n[        5       nU H�  n[	        U5      S:w  a  [
        R                  " SU 35      eUu  pEX@;  d  XP;  a  [
        R                  " SU S35      eXE:X  a    gU R                  XE5      (       d    gXB;   d  XR;   a    gUR                  U5        M‘     [	        U5      [	        U 5      :H  $ )a#  Return True if ``matching`` is a perfect matching for ``G``

A *perfect matching* in a graph is a matching in which exactly one edge
is incident upon each vertex.

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

matching : dict or set
    A dictionary or set representing a matching. If a dictionary, it
    must have ``matching[u] == v`` and ``matching[v] == u`` for each
    edge ``(u, v)`` in the matching. If a set, it must have elements
    of the form ``(u, v)``, where ``(u, v)`` is an edge in the
    matching.

Returns
-------
bool
    Whether the given set or dictionary represents a valid perfect
    matching in the graph.

Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (2, 3), (2, 4), (3, 5), (4, 5), (4, 6)])
>>> my_match = {1: 2, 3: 5, 4: 6}
>>> nx.is_perfect_matching(G, my_match)
True

r"   r#   r$   r%   Fr&   r   s         r   r   r   Ð   sÄ   € ô@ �(œD×!Ñ!Ü'¨Ó1ˆä‹E€EÛˆÜˆt‹9˜‹>Ü×"Ò"Ð%CÀDÀ6Ð#JÓKÐKØ‰ˆØ‹:˜›Ü×"Ò"Ð%<¸T¸FÐBUÐ#VÓWÐWØ‹6ÙØ�z‰z˜!×ÑÙØ‹:˜›ÙØ�‰�TÖñ ô ˆu‹:œ˜Q›ÑÐr   Úweight)Ú
edge_attrsc                 ó  ^• [        U R                  5      S:X  a  [        U SUS9$ U R                  USS9nS[        S U 5       5      -   m[        R
                  " 5       nU4S jU 5       nUR                  XAS9  [        USUS9$ )	ae  Compute a minimum-weight maximum-cardinality matching of `G`.

The minimum-weight maximum-cardinality matching is the matching
that has the minimum weight among all maximum-cardinality matchings.

Use the maximum-weight algorithm with edge weights subtracted
from the maximum weight of all edges.

A matching is a subset of edges in which no node occurs more than once.
The weight of a matching is the sum of the weights of its edges.
A maximal matching cannot add more edges and still be a matching.
The cardinality of a matching is the number of matched edges.

This method replaces the edge weights with 1 plus the maximum edge weight
minus the original edge weight.

new_weight = (max_weight + 1) - edge_weight

then runs :func:`max_weight_matching` with the new weights.
The max weight matching with these new weights corresponds
to the min weight matching using the original weights.
Adding 1 to the max edge weight keeps all edge weights positive
and as integers if they started as integers.

Read the documentation of `max_weight_matching` for more information.

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

weight: string, optional (default='weight')
   Edge data key corresponding to the edge weight.
   If key not found, uses 1 as weight.

Returns
-------
matching : set
    A minimal weight matching of the graph.

See Also
--------
max_weight_matching
r   T)Úmaxcardinalityr-   é   )ÚdataÚdefaultc              3   ó,   #   • U  H
  u    pUv •  M     g 7f©N© )Ú.0Ú_Úws      r   Ú	<genexpr>Ú&min_weight_matching.<locals>.<genexpr>7  s   é € Ð2ª'™w˜q !�ª'ùs   ‚c              3   ó8   >#   • U  H  u  po1UTU-
  4v •  M     g 7fr5   r6   )r7   r   r   r9   Ú
max_weights       €r   r:   r;   9  s   øé € Ð;²7©¨¨a��J ‘NÕ#²7ùs   ƒ©r-   )r)   r   r	   Úmaxr   ÚGraphÚadd_weighted_edges_from)r   r-   ÚG_edgesÚInvGr   r=   s        @r   r
   r
     s�   ø€ ô` ˆ1�7‰7ƒ|�qÓÜ" 1°TÀ&ÑIÐIØ�g‰g˜6¨1ˆgÐ-€GØ”SÑ2©'Ó2Ó2Ñ2€JÜ�8Š8‹:€DÜ;±7Ó;€EØ× Ñ  Ð Ñ6Ü˜t°DÀÑHÐHr   c                 ó  ^ ^^^^^^^^^ ^!^"^#^$^%^&^'^(^)^*•  " S S5      m " U4S jS5      m[        T 5      m$T$(       d
  [        5       $ SnSnT R                  SS9 HV  u  pVnUR                  TS5      nXV:w  a  Xƒ:”  a  UnU=(       a)    [	        [        U5      5      R                  S	5      S   S
;   nMX     0 m(0 m&0 m'[        [        T$T$5      5      m%[        [        T$[        S5      5      5      m"[        [        T$T$5      5      m 0 m[        [        T$[        U5      5      5      m#0 m!0 m/ m)U U#U4S jm*UUUU U%U&U'U(U)4	S jmUU U%U&U'U(4S jn	UU UU U!U"U%U&U'U(U)U*4S jn
UUUUU U!U"U%U&U'U(4S jnUU U"U(4S jmUUU U%U&U'U(4S jnU U!U"U#U$U(UU4S jn T&R                  5         T'R                  5         TR                  5         T! H
  nSUl        M     TR                  5         / T)SS& T$ H,  nUT(;  d  M  T&R                  T%U   5      b  M"  T" USS5        M.     Sn T)(       Gaœ  U(       Gd”  T)R                  5       nT&T%U      S:X  d   eT R                  U5       GHO  nUU:X  a  M  T%U   nT%U   nUU:X  a  M  UU4T;  a  T*" UU5      nUS::  a  S=TUU4'   TUU4'   UU4T;   a‡  T&R                  U5      c  T" USU5        Mi  T&R                  U5      S:X  a'  U	" UU5      nUTLa  U
" UUU5        M˜  U" UU5        Sn  O¯T&R                  U5      c  T&U   S:X  d   eST&U'   UU4T'U'   MÐ  MÒ  T&R                  U5      S:X  a+  TR                  U5      b  WT*" TU   6 :  a
  UU4TU'   GM  GM  T&R                  U5      b  GM'  TR                  U5      b  WT*" TU   6 :  d  GMH  UU4TU'   GMR     T)(       a
  U(       d  GM”  U(       a  GO´SnS=n=nnT(       d  Sn[        T#R                  5       5      nT R!                  5        HM  nT&R                  T%U   5      b  M  TR                  U5      c  M.  T*" TU   6 nUS:X  d  UU:  d  MD  UnSnTU   nMO     T" Hr  nT"U   b  M  T&R                  U5      S:X  d  M"  TR                  U5      c  M6  T*" TU   6 nU(       a  US-  S:X  d   eUS-  nOUS-  nUS:X  d  UU:  d  Mi  UnSnTU   nMt     T! H<  nT"U   b  M  T&R                  U5      S:X  d  M"  US:X  d  T!U   U:  d  M3  T!U   nSnUnM>     US:X  a.  T(       d   eSn[#        S[        T#R                  5       5      5      nT$ HQ  nT&R                  T%U   5      S:X  a  T#U==   U-  ss'   M*  T&R                  T%U   5      S:X  d  MD  T#U==   U-  ss'   MS     T! HS  nT"U   b  M  T&R                  U5      S:X  a  T!U==   U-  ss'   M/  T&R                  U5      S:X  d  MF  T!U==   U-  ss'   MU     US:X  a  O„US:X  a3  Uu  nnT&T%U      S:X  d   eS=TUU4'   TUU4'   T)R%                  U5        OHUS:X  a3  Uu  nnS=TUU4'   TUU4'   T&T%U      S:X  d   eT)R%                  U5        OUS:X  a	  U" US5        GMa  T( H  nT(T(U      U:X  a  M   e   U(       d  O^[        T!R'                  5       5       H>  nUT!;  a  M  T"U   b  M  T&R                  U5      S:X  d  M*  T!U   S:X  d  M5  U" US5        M@     GMh  U(       a  U" 5         [)        T(5      $ )a  Compute a maximum-weighted matching of G.

A matching is a subset of edges in which no node occurs more than once.
The weight of a matching is the sum of the weights of its edges.
A maximal matching cannot add more edges and still be a matching.
The cardinality of a matching is the number of matched edges.

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

maxcardinality: bool, optional (default=False)
   If maxcardinality is True, compute the maximum-cardinality matching
   with maximum weight among all maximum-cardinality matchings.

weight: string, optional (default='weight')
   Edge data key corresponding to the edge weight.
   If key not found, uses 1 as weight.


Returns
-------
matching : set
    A maximal matching of the graph.

 Examples
--------
>>> G = nx.Graph()
>>> edges = [(1, 2, 6), (1, 3, 2), (2, 3, 1), (2, 4, 7), (3, 5, 9), (4, 5, 3)]
>>> G.add_weighted_edges_from(edges)
>>> sorted(nx.max_weight_matching(G))
[(2, 4), (5, 3)]

Notes
-----
If G has edges with weight attributes the edge data are used as
weight values else the weights are assumed to be 1.

This function takes time O(number_of_nodes ** 3).

If all edge weights are integers, the algorithm uses only integer
computations.  If floating point weights are used, the algorithm
could return a slightly suboptimal matching due to numeric
precision errors.

This method is based on the "blossom" method for finding augmenting
paths and the "primal-dual" method for finding a matching of maximum
weight, both methods invented by Jack Edmonds [1]_.

Bipartite graphs can also be matched using the functions present in
:mod:`networkx.algorithms.bipartite.matching`.

References
----------
.. [1] "Efficient Algorithms for Finding Maximum Matching in Graphs",
   Zvi Galil, ACM Computing Surveys, 1986.
c                   ó   • \ rS rSrSrSrg)Ú#max_weight_matching.<locals>.NoNodeiŠ  z-Dummy value which is different from any node.r6   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r6   r   r   ÚNoNoderF   Š  s   † Ü;r   rM   c                   ó.   >• \ rS rSrSr/ SQrU 4S jrSrg)Ú$max_weight_matching.<locals>.Blossomi�  z7Representation of a non-trivial blossom or sub-blossom.)Úchildsr   Úmybestedgesc              3   óÎ   >#   • / U R                   QnU(       aK  UR                  5       n[        UT5      (       a  UR                  UR                   5        OUv •  U(       a  MJ  g g 7fr5   )rP   Úpopr'   Úextend)ÚselfÚstackÚtÚBlossoms      €r   ÚleavesÚ+max_weight_matching.<locals>.Blossom.leavesŸ  sJ   øé € Ø"�d—k‘k�NˆEÞØ—I‘I“K�Ü˜a ×)Ñ)Ø—L‘L §¡Õ*à’G÷ ’%ùs   ƒAA%Á#A%r6   N)rG   rH   rI   rJ   rK   Ú	__slots__rY   rL   )rX   s   €r   rX   rO   �  s   ø† ÙEâ6ˆ	÷	ð 	r   rX   r   T©r2   r1   Ú')ÚintÚlongNc                 óR   >• TU    TU   -   STU    U   R                  TS5      -  -
  $ )Nr"   r1   )Úget)r   r9   r   Údualvarr-   s     €€€r   ÚslackÚ"max_weight_matching.<locals>.slackü  s3   ø€ Ø�q‰z˜G A™JÑ&¨¨Q¨q©T°!©W¯[©[¸ÀÓ-CÑ)CÑCÐCr   c                 óz  >	• T	U    nT
R                  U 5      c  T
R                  U5      b   eU=T
U '   T
U'   Ub  X 4=TU '   TU'   O
S =TU '   TU'   S =TU '   TU'   US:X  aC  [        UT5      (       a   TR                  UR                  5       5        g TR	                  U5        g US:X  a  TU   nT" TU   SU5        g g )Nr1   r"   )ra   r'   rT   rY   Úappend)r9   rW   r   ÚbÚbaserX   ÚassignLabelÚbestedgeÚblossombaseÚ	inblossomÚlabelÚ	labeledgeÚmateÚqueues        €€€€€€€€€r   ri   Ú(max_weight_matching.<locals>.assignLabel  sÔ   ø€ Ø�a‰LˆØ�y‰y˜‹|Ñ#¨¯	©	°!«Ñ(<Ð<Ð<ØÐˆˆa‰�5˜‘8Ø‰=Ø+,¨&Ð0ˆI�a‰L˜9 Qš<à*.Ð.ˆI�a‰L˜9 Q™<Ø$(Ð(ˆ�‰�h˜q‘kØ�‹6ä˜!˜W×%Ñ%Ø—‘˜QŸX™X›ZÕ(à—‘˜Q•Ø�!‹Vð ˜q‘>ˆDÙ˜˜T™
 A tÕ,ð r   c                 óT  >• / nTnU TLa�  TU    nTU   S-  (       a  TU   nOwTU   S:X  d   eUR                  U5        STU'   T	U   c  TU   T
;  d   eTn O4T	U   S   T
TU      :X  d   eT	U   S   n TU    nTU   S:X  d   eT	U   S   n UTLa  XpU TLa  M�  U H  nSTU'   M
     U$ )Né   r1   é   r   r"   )rf   )r   r9   Úpathrh   rg   rM   rk   rl   rm   rn   ro   s        €€€€€€r   ÚscanBlossomÚ(max_weight_matching.<locals>.scanBlossom  sü   ø€ àˆØˆØ�vŠoà˜!‘ˆAØ�Q‰x˜!�|Ø" 1‘~�ØØ˜‘8˜q“=Ð �=Ø�K‰K˜ŒNØˆE�!‰Hà˜‰|Ñ#à" 1‘~¨TÓ1Ð1Ð1Ø‘à  ‘| A‘¨$¨{¸1©~Ñ*>Ó>Ð>Ð>Ø˜a‘L ‘O�Ø˜a‘L�Ø˜Q‘x 1“}Ð$�}à˜a‘L ‘O�à˜ŠØ�1ð/ �vŒoó2 ˆAØˆE�!‹Hñ ð ˆr   c                 ó  >• TU    nTU   nTU   nT" 5       nU TU'   S TU'   UTU'   / =Ul         nX4/=Ul        nXC:w  ad  UTU'   UR                  U5        UR                  TU   5        TU   S:X  d  TU   S:X  a  TU   S   TTU      :X  d   eTU   S   nTU   nXC:w  a  Md  UR                  U5        UR                  5         UR                  5         XS:w  ao  UTU'   UR                  U5        UR                  TU   S   TU   S   45        TU   S:X  d  TU   S:X  a  TU   S   TTU      :X  d   eTU   S   nTU   nXS:w  a  Mo  TU   S:X  d   eSTU'   TU   TU'   STU'   UR	                  5        H%  nTTU      S:X  a  TR                  U5        UTU'   M'     0 n	U Hÿ  n[        UT5      (       ae  UR                  b  UR                  n
S Ul        OmUR	                  5        VVs/ s H&  nTR                  U5        H  o!U:w  d  M
  X4PM     M(     n
nnO)TR                  U5       Vs/ s H  o$U:w  d  M
  XB4PM     n
nU
 HQ  nUu  pÍTU   U:X  a  XÜpÜTU   nXæ:w  d  M  TR                  U5      S:X  d  M5  Xé;  d  T" XÍ5      T" Xž   6 :  d  MM  X¹U'   MS     S TU'   GM     [        U	R                  5       5      Ul        S nS TU'   UR                   H  nT" U6 nUb  UW:  d  M  UnUnM     UTU'   g s  snnf s  snf )Nr"   r1   r   )rP   r   rf   ÚreverserY   r'   rQ   Ú	neighborsra   ÚlistÚvalues)rh   r   r9   ÚbbÚbvÚbwrg   ru   ÚedgsÚ
bestedgetoÚnblistÚkÚiÚjÚbjÚ
mybestedgeÚkslackÚmybestslackrX   r   rj   rk   ÚblossomdualÚblossomparentrl   rm   rn   ro   rp   rc   s                     €€€€€€€€€€€€r   Ú
addBlossomÚ'max_weight_matching.<locals>.addBlossom?  sn  ø€ Ø�t‰_ˆØ�q‰\ˆØ�q‰\ˆá‹IˆØˆ�A‰Øˆ�aÑØˆ�bÑàÐˆŒ�4Ø˜&˜Ð!ˆŒ�$à‹hà !ˆM˜"ÑØ�K‰K˜ŒOØ�K‰K˜	 "™Ô&Ø˜‘9 “>Ø�b‘	˜Q“ 9¨R¡=°Ñ#3°t¸KÈ¹OÑ7LÓ#Lðð ð ˜"‘˜aÑ ˆAØ˜1‘ˆBð �hð 	�‰�BŒØ�‰ŒØ�‰Œà‹hà !ˆM˜"ÑØ�K‰K˜ŒOØ�K‰K˜ 2™ qÑ)¨9°R©=¸Ñ+;Ð<Ô=Ø˜‘9 “>Ø�b‘	˜Q“ 9¨R¡=°Ñ#3°t¸KÈ¹OÑ7LÓ#Lðð ð ˜"‘˜aÑ ˆAØ˜1‘ˆBð �hð �R‰y˜A‹~Ðˆ~Øˆˆa‰Ø  ‘}ˆ	�!‰àˆ�A‰à—‘–ˆAØ�Y˜q‘\Ñ" aÓ'ð —‘˜Q”ØˆI�a‹Lñ ð ˆ
ÛˆBÜ˜"˜g×&Ñ&Ø—>‘>Ñ-àŸ^™^�Fà%)�B•Nð
 )+¯	©	¬ôÚ(3 1¸Q¿[¹[È¿^¸ÐTUÉv›˜›¹^™©ð ñ �Fð ,-¯;©;°r¬?ÓFª? aÀA¹g›'˜2›'©?�ÐFÛ�Ø‘�Ø˜Q‘< 1Ó$Ø�qØ˜q‘\�à•GØŸ	™	 "›¨Õ*ØÓ.±5¸³;ÁÈ
ÉÐAWÕ3Wà%&˜r“Nñ ð  ˆH�RŒLñ7 ô8 ˜Z×.Ñ.Ó0Ó1ˆŒàˆ
Øˆ�‰Ø—”ˆAÙ˜A�YˆFØÑ! V¨kÕ%9Ø�
Ø$’ñ	 ð
 !ˆ�Šùó7ùò Gs   Ç+K8ÈK8È/	K>È<K>c                 óÄ   >• UUUU	U
UUUUUU4S jnU" X5      /nU(       a?  US   nU H  nUR                  U" XQ5      5          O   UR                  5         U(       a  M>  g g )Nc              3   óŒ  >#   • U R                    HR  nS TU'   [        UT5      (       a4  U(       a  TU   S:X  a  Uv •  M/  UR                  5        H  nUTU'   M
     MM  UTU'   MT     U(       Gd  TR                  U 5      S:X  Ga   TTU    S      nU R                   R	                  U5      nUS-  (       a  U[        U R                   5      -  nSnOSnTU    u  p7US:w  a”  US:X  a  U R                  U   u  p‰OU R                  US-
     u  p˜S TU'   S TU	'   T" USU5        S=TX‰4'   TX˜4'   XV-  nUS:X  a  U R                  U   u  p7OU R                  US-
     u  psS=TX74'   TXs4'   XV-  nUS:w  a  M”  U R                   U   n
S=TU'   TU
'   X74=TU'   TU
'   S TU
'   XV-  nU R                   U   U:w  aÒ  U R                   U   nTR                  U5      S:X  a  XV-  nM=  [        UT5      (       a0  UR                  5        H  nTR                  U5      (       d  M    O   OUnTR                  U5      (       a6  TU   S:X  d   eTU   U:X  d   eS TU'   S TTTU      '   T" USTU   S   5        XV-  nU R                   U   U:w  a  MÒ  TR                  U S 5        TR                  U S 5        TR                  U S 5        TU 	 TU 	 TU 	 g 7f)Nr   r"   r1   éÿÿÿÿT)rP   r'   rY   ra   Úindexr)   r   rS   )rg   ÚendstageÚsr   Ú
entrychildr…   Újstepr9   ÚpÚqr   r~   rX   Ú	allowedgeri   rj   rk   rŠ   r‹   rl   rm   rn   ro   s               €€€€€€€€€€€r   Ú_recurseÚ<max_weight_matching.<locals>.expandBlossom.<locals>._recurse¤  sþ  øé € à—X”X�Ø#'�˜aÑ Ü˜a ×)Ñ)Þ K°¡N°aÓ$7àœà!"§¡¦˜AØ+,˜I a›Ló ",ð $%�I˜a“Lñ ÷  %§)¡)¨A£,°!Ô"3ð ' y°¡|°A¡Ñ7�
à—H‘H—N‘N :Ó.�Ø�q—5àœ˜QŸX™X›Ñ&�AØ‘Eð �Eà  ‘|‘�Ø˜1“fà “zØ Ÿw™w q™z™˜˜1à Ÿw™w q¨1¡u™~™˜Ø#�E˜!‘HØ#�E˜!‘HÙ  1 aÔ(à<@Ð@�I˜q˜fÑ%¨	°1°&Ñ(9Ø‘J�AØ “zØ Ÿw™w q™z™˜˜1à Ÿw™w q¨1¡u™~™˜à<@Ð@�I˜q˜fÑ%¨	°1°&Ñ(9Ø‘J�Að% ˜1•fð* —X‘X˜a‘[�Ø'(Ð(��a‘˜5 ™9Ø01¨vÐ5�	˜!‘˜y¨™}Ø#�˜‘à‘
�Ø—h‘h˜q‘k ZÓ/ð Ÿ™ !™�BØ—y‘y “}¨Ó)ð ™
˜Ù Ü! " g×.Ñ.Ø!#§¡¦˜AØ$Ÿy™y¨Ÿ|›|Ù %ò "-ð ˜ð —y‘y —|‘|Ø$ Q™x¨1›}Ð,˜}Ø(¨™|¨rÓ1Ð1Ð1Ø#'˜˜a™Ø7;˜˜d ;¨r¡?Ñ3Ñ4Ù# A q¨)°A©,°q©/Ô:Ø‘J�Að1 —h‘h˜q‘k ZÕ/ð4 �I‰I�a˜ÔØ�M‰M˜!˜TÔ"Ø�L‰L˜˜DÔ!Ø˜aÐ Ø˜A�Ø˜A‘ùs   ƒE-KÅ2B"KÈA*KÊA Kr�   ©rf   rS   )rg   r’   r™   rV   Útopr“   rX   r˜   ri   rj   rk   rŠ   r‹   rl   rm   rn   ro   s         €€€€€€€€€€€r   ÚexpandBlossomÚ*max_weight_matching.<locals>.expandBlossomž  s[   ø€ ÷[	÷ [	ñD ˜!Ó&Ð'ˆÞØ˜‘)ˆCÛ�Ø—‘™X aÓ2Ô3Ùñ ð —	‘	”÷ Šer   c                 ó°   >• UUUU	4S jnU" X5      /nU(       a<  US   nU H  nUR                  U" U6 5          O   UR                  5         U(       a  M;  g g )Nc              3   óò  >#   • UnT
U   U :w  a  T
U   nT
U   U :w  a  M  [        UT5      (       a  X!4v •  U R                  R                  U5      =p4US-  (       a  U[        U R                  5      -  nSnOSnUS:w  a�  XE-  nU R                  U   nUS:X  a  U R                  U   u  pgOU R                  US-
     u  pv[        UT5      (       a  X&4v •  XE-  nU R                  U   n[        UT5      (       a  X'4v •  UTU'   UTU'   US:w  a  M�  U R                  US  U R                  S U -   U l        U R                  US  U R                  S U -   U l        T	U R                  S      T	U '   T	U    U:X  d   eg 7f)Nr1   r�   r   )r'   rP   r‘   r)   r   )rg   r   rW   r„   r…   r•   r9   ÚxrX   rk   r‹   ro   s           €€€€r   r™   Ú=max_weight_matching.<locals>.augmentBlossom.<locals>._recurse  sŠ  øé € ð ˆAØ Ñ" aÓ'Ø! !Ñ$�ð   Ñ" aÕ'ô ˜!˜W×%Ñ%Ø�f’à—H‘H—N‘N 1Ó%Ð%ˆAØ�1�uà”S˜Ÿ™“]Ñ"�Ø‘ð �à�q“&à‘
�Ø—H‘H˜Q‘K�Ø˜A“:ØŸ7™7 1™:‘D�A�qàŸ7™7 1 q¡5™>‘D�AÜ˜a ×)Ñ)Ø˜&’Là‘
�Ø—H‘H˜Q‘K�Ü˜a ×)Ñ)Ø˜&’Là��Q‘Ø��Q‘ð# �q•&ð& —x‘x  �| a§h¡h¨r° lÑ2ˆAŒHØ—g‘g˜a˜b�k A§G¡G¨B¨Q KÑ/ˆAŒGØ(¨¯©°!©Ñ5ˆK˜‰NØ˜q‘> QÓ&Ð&Ñ&ùs   ƒE7ŸC-E7ÄA)E7r�   r›   )
rg   r   r™   rV   rœ   ÚargsrX   rk   r‹   ro   s
         €€€€r   ÚaugmentBlossomÚ+max_weight_matching.<locals>.augmentBlossom  sW   ø€ ÷)	'ð )	'ñ` ˜!“Ð ˆÞØ˜‘)ˆCÛ�Ø—‘™X t˜_Ô-Ùñ ð —	‘	”÷ Šer   c                 óh  >• X4X44 H§  u  p# T
U   nTU   S:X  d   eTU   c	  T	U   T;  d  TU   S   TT	U      :X  d   e[        UT5      (       a  T" XB5        UTU'   TU   c  M_  TU   S   nT
U   nTU   S:X  d   eTU   u  p#T	U   U:X  d   e[        UT5      (       a  T" Xc5        UTU'   M£     g )Nr1   r   r"   )r'   )r   r9   r“   r…   ÚbsrW   ÚbtrX   r¤   rk   rl   rm   rn   ro   s          €€€€€€€r   ÚaugmentMatchingÚ,max_weight_matching.<locals>.augmentMatchingS  s  ø€ Ø�V˜a˜VÓ$‰DˆAð Ø˜q‘\�Ø˜R‘y A“~Ð%�~Ø! "™Ñ-°+¸b±/ÈÓ2MØ˜b‘M !Ñ$¨¨[¸©_Ñ(=Ó=ðð ô ˜b '×*Ñ*Ù" 2Ô)à��Q‘à˜R‘=Ñ(áØ˜b‘M !Ñ$�Ø˜q‘\�Ø˜R‘y A“~Ð%�~à  ‘}‘�à" 2‘¨!Ó+Ð+Ð+Ü˜b '×*Ñ*Ù" 2Ô)à��Q‘ñ3 ò	 %r   c                  ór  >• T(       a%  [        S[        TR                  5       5      * 5      n OSn [        TR                  5       5      U -   S:¼  d   e[        T5      S:X  d  [        TR                  5       5      S:¼  d   eTR	                  SS9 GH$  u  pnUR                  TS5      nX:X  a  M   TU   TU   -   SU-  -
  nU/nU/nTUS      b"  UR                  TUS      5        TUS      b  M"  TUS      b"  UR                  TUS      5        TUS      b  M"  UR                  5         UR                  5         [        Xg5       H  u  p‰X‰:w  a    OUSTU   -  -  nM     US:¼  d   eTR                  U5      U:X  d  TR                  U5      U:X  d  GM  TU   U:X  a	  TU   U:X  d   eUS:X  a  GM%   e   T H  n
U
T;   a  M  TU
   U -   S:X  a  M   e   T H[  nTU   S:”  d  M  [        UR                  5      S-  S:X  d   eUR                  SS S2    H  u  pTU   U:X  a  TU   U:X  a  M   e   M]     g )Nr   Tr\   r1   r"   r�   )	r?   Úminr|   r)   r   ra   rf   ry   Úzip)Úvdualoffsetr„   r…   ÚdÚwtr“   Ú	iblossomsÚ	jblossomsÚbir†   r   rg   r   rŠ   r‹   rb   Úgnodesro   r0   r-   s               €€€€€€€€r   ÚverifyOptimumÚ*max_weight_matching.<locals>.verifyOptimumt  s`  ø€ Þô ˜a¤# g§n¡nÓ&6Ó"7Ð!7Ó8‰KàˆKä�7—>‘>Ó#Ó$ {Ñ2°aÓ7Ð7Ð7Ü�;Ó 1Ó$¬¨K×,>Ñ,>Ó,@Ó(AÀQÓ(FÐFÐFð —w‘w D�wÔ)‰GˆA�!Ø—‘�v˜qÓ!ˆBØ‹vÙØ˜‘
˜W Q™ZÑ'¨!¨b©&Ñ0ˆAØ˜ˆIØ˜ˆIØ 	¨"¡Ñ.Ñ:Ø× Ñ  ¨y¸©}Ñ!=Ô>ð   	¨"¡Ñ.Ó:à 	¨"¡Ñ.Ñ:Ø× Ñ  ¨y¸©}Ñ!=Ô>ð   	¨"¡Ñ.Ó:à×ÑÔØ×ÑÔÜ˜iÖ3‘�Ø“8ÙØ�Q˜ R™Ñ(Ñ(’ñ 4ð ˜“6ˆM�6Ø�x‰x˜‹{˜aÓ 4§8¡8¨A£;°!Ö#3Ø˜A‘w !“|¨¨Q©°1«Ð4Ð4Ø˜A–v��vñ) *ó, ˆAØ˜•I '¨!¡*¨{Ñ":¸aÕ"?Ð?Ð?ñ ó ˆAØ˜1‰~ Õ!Ü˜1Ÿ7™7“| aÑ'¨1Ó,Ð,Ð,ØŸG™G A D q DœM‘D�AØ ™7 a›<¨D°©G°q­LÐ8Ð8ó *ò r   r"   r�   g       @é   rs   F)r{   r   r   ra   ÚstrÚtypeÚsplitr(   r­   r   ÚclearrQ   rS   rz   r¬   r|   r   r?   rf   Úkeysr    )+r   r0   r-   Ú	maxweightÚ
allintegerr„   r…   r¯   r°   rv   rŒ   r�   r©   rµ   rg   r   Ú	augmentedr9   r~   r   rˆ   rh   Ú	deltatypeÚdeltaÚ	deltaedgeÚdeltablossomrX   rM   r˜   ri   r¤   rj   rk   rŠ   r‹   rb   r´   rl   rm   rn   ro   rp   rc   s+   ```                       @@@@@@@@@@@@@@@@@r   r	   r	   >  sx  ÿÿû€ ÷X<ñ <÷ô ô8 �!‹W€FÞÜ‹uˆð €IØ€JØ—7‘7 �7Ó%‰ˆˆaØ�U‰U�6˜1ÓˆØ‹6�b“nØˆIØ×T¤S¬¨b«£]×%8Ñ%8¸Ó%=¸aÑ%@ÀOÑ%SŠ
ñ	 &ð €Dð €Eð €Iô ”S˜ Ó(Ó)€Iô
 œ˜V¤V¨D£\Ó2Ó3€Mô ”s˜6 6Ó*Ó+€Kð €Hô ”3�vœv iÓ0Ó1Ó2€Gð
 €Kð
 €Ið €E÷D÷
-õ -÷2 ò  ÷J\!÷ \!ð \!÷~o÷ o÷h=ð =÷Bó ÷B)9ô )9ðZ ð 	�‰ŒØ�‰Ôð 	�‰ÔÛˆAØ ˆAŽMñ ð
 	�‰Ôð ˆ‰aˆó ˆAØ˜• 5§9¡9¨Y°q©\Ó#:Ó#BÙ˜A˜q $Ö'ñ ð
 ˆ	Ø÷ §	à—I‘I“K�Ø˜Y q™\Ñ*¨aÓ/Ð/Ð/ð Ÿ™ QŸ�AØ˜A“vÙ à" 1™�BØ" 1™�BØ˜R“xá Ø˜1�v YÓ.Ù!& q¨!£˜Ø! Q›;àDHÐH˜I q¨! fÑ-°	¸1¸a¸&Ñ0AØ˜1�v Ó*Ø Ÿ9™9 R›=Ñ0ñ (¨¨1¨aÖ0Ø"ŸY™Y r›]¨aÓ/ñ $/¨q°!Ó#4˜DØ#¨6Ò1ñ !+¨4°°AÖ 6ñ !0°°1Ô 5Ø,- 	Ù %Ø"ŸY™Y q›\Ñ1ð
 $)¨¡9°£>Ð1 >Ø'(˜E !™HØ,-¨q¨6˜I a›Lñ 2ð Ÿ™ 2›¨!Ó+ð $Ÿ<™<¨Ó+Ñ3°vÁÀxÐPRÁ|Ð@TÓ7TØ,-¨q¨6˜H RœLò 8UàŸ™ 1›Ô-ð $Ÿ<™<¨›?Ñ2°f¹uÀhÈqÁkÐ?RÖ6RØ+,¨a¨&˜H QœKñi (ö §	¡	öx Ùð ˆIØ/3Ð3ˆEÐ3�I ö "Ø�	Ü˜GŸN™NÓ,Ó-�ð —W‘W–Y�Ø—9‘9˜Y q™\Ó*Ó2°x·|±|ÀA³Ó7RÙ˜x¨™{Ð+�AØ  B“¨!¨e­)Ø !˜Ø$%˜	Ø$,¨Q¡Kš	ñ ó #�à! !Ñ$Ó,ØŸ	™	 !›¨Õ)Ø Ÿ™ Q›Ó3á" H¨Q¡KÐ0�FÞ!Ø &¨¡
¨qÓ0Ð0Ð0Ø" a™K™à" S™L˜Ø  B“¨!¨e­)Ø !˜Ø$%˜	Ø$,¨Q¡Kš	ñ #ó$ !�à! !Ñ$Ó,ØŸ	™	 !›¨Õ)Ø" b›¨K¸©N¸UÕ,Bà'¨™N�EØ !�IØ#$’Lñ !ð ˜B‹ö &Ð%�~Ø�	Ü˜Aœs 7§>¡>Ó#3Ó4Ó5�ó �Ø—9‘9˜Y q™\Ó*¨aÓ/à˜A“J %Ñ'•JØ—Y‘Y˜y¨™|Ó,°Õ1à˜A“J %Ñ'•Jñ ó !�Ø  Ñ#Ó+Ø—y‘y “| qÓ(à# A›¨%Ñ/�ØŸ™ 1›¨Õ*à# A›¨%Ñ/�ñ !ð ˜A‹~àØ˜a“à"‘��AØ˜Y q™\Ñ*¨aÓ/Ð/Ð/Ø8<Ð<�	˜1˜a˜&Ñ! I¨q°!¨fÑ$5Ø—‘˜Q•Ø˜a“à"‘��AØ8<Ð<�	˜1˜a˜&Ñ! I¨q°!¨fÑ$5Ø˜Y q™\Ñ*¨aÓ/Ð/Ð/Ø—‘˜Q•Ø˜a“á˜l¨EÔ2òQ óZ ˆAØ˜˜Q™‘= AÕ%Ð%Ð%ñ ö Øô �k×&Ñ&Ó(Ö)ˆAØ˜Ó#ÙØ˜QÑÓ'¨E¯I©I°a«L¸AÕ,=À+ÈaÁ.ÐTUÕBUÙ˜a Ö&ñ	 *òc öp ÙŒä Ó%Ð%r   r>   )Fr-   )rK   Ú	itertoolsr   r   Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r    r   r   r   r
   r	   r6   r   r   Ú<module>rÉ      s  ðÙ Aç *ã Ý .ò€ñ �\Ó"Ù�ZÓ Ø×Ññ$ó ó !ó #ð$òNð2 ×Ññ9ó ð9ðx ×Ññ:ó ð:ðz ×Ññ0 ó ð0 ñf �\Ó"Ù�ZÓ Ø×Ò˜XÑ&ó4Ió 'ó !ó #ð4Iñn �\Ó"Ù�ZÓ Ø×Ò˜XÑ&ó{&ó 'ó !ó #ñ{&r   