Ë
    ÷Ç:j%­  ã                   ó¶  — d Z ddlmZmZ ddlZddlmZ g d¢Z ed«       ed«      ej                  d„ «       «       «       Z
d	„ Zej                  d
„ «       Zej                  d„ «       Zej                  d„ «       Z ed«       ed«       ej                  d¬«      dd„«       «       «       Z ed«       ed«       ej                  d¬«      dd„«       «       «       Zy)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                 óÆ   — t        «       }t        «       }| j                  «       D ]9  }|\  }}||vsŒ||vsŒ||k7  sŒ|j                  |«       |j                  |«       Œ; |S )a™  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         úq/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/networkx/algorithms/matching.pyr   r      sd   € ô< ‹u€HÜ‹E€EØ—‘“	ò ˆð ‰ˆˆ1Ø�EŠ>˜a ušn°°a³Ø�L‰L˜ÔØ�L‰L˜Õðð €Oó    c                 óÀ   — t        «       }| j                  «       D ]@  }|\  }}||f|v s||v rŒ||k(  rt        j                  d|› �«      ‚|j	                  |«       ŒB |S )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    <   sp   € ô ‹E€EØ—‘Ó ò ˆØ‰ˆˆ1Øˆqˆ6�U‰?˜d e™mØØ�Š6Ü×"Ñ"Ð%JÈ4È&Ð#QÓRÐRØ�	‰	�$�ðð €Lr   c                 ó`  — t        |t        «      rt        |«      }t        «       }|D ]„  }t	        |«      dk7  rt        j                  d|› �«      ‚|\  }}|| vs|| vrt        j                  d|› d�«      ‚||k(  r y| j                  ||«      s y||v s||v r y|j                  |«       Œ† y)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Ø‰ˆˆ1Ø�A‰:˜ !™Ü×"Ñ"Ð%<¸T¸FÐBUÐ#VÓWÐWØ�Š6ÙØ�z‰z˜!˜QÔÙØ�‰:˜˜e™ÙØ�‰�TÕðð r   c                 ó  — t        |t        «      rt        |«      }t        «       }t        «       }|D ]¨  }t	        |«      dk7  rt        j                  d|› �«      ‚|\  }}|| vs|| vrt        j                  d|› d�«      ‚||k(  r y| j                  ||«      s y||v s||v r y|j                  |«       |j                  |«       |j                  ||f«       Œª | j                  D ]  \  }}||f|vsŒ||vsŒ||vsŒ||k7  sŒ y y)ag  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Ø‰ˆˆ1Ø�A‰:˜ !™Ü×"Ñ"Ð%<¸T¸FÐBUÐ#VÓWÐWØ�Š6ÙØ�z‰z˜!˜QÔÙØ�‰:˜˜e™ÙØ�‰�TÔØ�	‰	�$ŒØ�	‰	�1�a�&Õðð$ —‘ò ‰ˆˆ1Øˆqˆ6˜Òà˜Š~ !¨5¢.°Q¸!³VÙð	ð
 r   c                 óŒ  — t        |t        «      rt        |«      }t        «       }|D ]„  }t	        |«      dk7  rt        j                  d|› �«      ‚|\  }}|| vs|| vrt        j                  d|› d�«      ‚||k(  r y| j                  ||«      s y||v s||v r y|j                  |«       Œ† t	        |«      t	        | «      k(  S )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Ø‰ˆˆ1Ø�A‰:˜ !™Ü×"Ñ"Ð%<¸T¸FÐBUÐ#VÓWÐWØ�Š6ÙØ�z‰z˜!˜QÔÙØ�‰:˜˜e™ÙØ�‰�TÕðô ˆu‹:œ˜Q›ÑÐr   Úweight)Ú
edge_attrsc                 ó   ‡— t        | j                  «      dk(  rt        | d|¬«      S | j                  |d¬«      }dt        d„ |D «       «      z   Št	        j
                  «       }ˆfd„|D «       }|j                  ||¬«       t        |d|¬«      S )	aå  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   ó(   K  — | ]
  \  }}}|–— Œ y ­w©N© )Ú.0Ú_Úws      r   ú	<genexpr>z&min_weight_matching.<locals>.<genexpr>7  s   è ø€ Ò2™w˜q ! QœÑ2ùs   ‚c              3   ó6   •K  — | ]  \  }}}||‰|z
  f–— Œ y ­wr5   r6   )r7   r   r   r9   Ú
max_weights       €r   r:   z&min_weight_matching.<locals>.<genexpr>9  s"   øè ø€ Ò;©¨¨1¨aˆa��J ‘NÔ#Ñ;ù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Ø× Ñ  ¨vÐ Ô6Ü˜t°DÀÔHÐHr   c                 óº  ‡ ‡‡‡‡‡‡‡‡‡ ‡!‡"‡#‡$‡%‡&‡'‡(‡)‡*—  G d„ d«      Š G ˆfd„d«      Št        ‰ «      Š$‰$s
t        «       S d}d}‰ j                  d¬«      D ]P  \  }}}|j                  ‰d«      }||k7  r||kD  r|}|xr( t	        t        |«      «      j                  d	«      d   d
v }ŒR i Š(i Š&i Š't        t        ‰$‰$«      «      Š%t        t        ‰$t        d«      «      «      Š"t        t        ‰$‰$«      «      Š i Št        t        ‰$t        |«      «      «      Š#i Š!i Šg Š)ˆ ˆ#ˆfd„Š*ˆˆˆˆ ˆ%ˆ&ˆ'ˆ(ˆ)f	d„Šˆˆ ˆ%ˆ&ˆ'ˆ(fd„}	ˆˆ ˆˆ ˆ!ˆ"ˆ%ˆ&ˆ'ˆ(ˆ)ˆ*fd„}
ˆˆˆˆˆ ˆ!ˆ"ˆ%ˆ&ˆ'ˆ(fd„}ˆˆ ˆ"ˆ(fd„Šˆˆˆ ˆ%ˆ&ˆ'ˆ(fd„}ˆ ˆ!ˆ"ˆ#ˆ$ˆ(ˆˆfd„}	 ‰&j                  «        ‰'j                  «        ‰j                  «        ‰!D ]	  }d|_        Œ ‰j                  «        g ‰)dd ‰$D ]&  }|‰(vsŒ‰&j                  ‰%|   «      �Œ ‰|dd«       Œ( d}	 ‰)�rk|�sh‰)j                  «       }‰&‰%|      dk(  sJ ‚‰ j                  |«      D �]0  }||k(  rŒ
‰%|   }‰%|   }||k(  rŒ||f‰vr ‰*||«      }|dk  rdx‰||f<   ‰||f<   ||f‰v r~‰&j                  |«      € ‰|d|«       Œ^‰&j                  |«      dk(  r% |	||«      }|‰ur |
|||«       ŒŠ |||«       d} n�‰&j                  |«      �Œ©‰&|   dk(  sJ ‚d‰&|<   ||f‰'|<   ŒÀ‰&j                  |«      dk(  r%‰j                  |«      � ‰*‰|   Ž k  sŒñ||f‰|<   Œù‰&j                  |«      ��Œ‰j                  |«      � ‰*‰|   Ž k  s�Œ*||f‰|<   �Œ3 ‰)r|s�Œh|r�nqd}dx}x}}‰sd}t        ‰#j                  «       «      }‰ j!                  «       D ]E  }‰&j                  ‰%|   «      �Œ‰j                  |«      €Œ* ‰*‰|   Ž }|dk(  s||k  sŒ=|}d}‰|   }ŒG ‰"D ]b  }‰"|   �Œ	‰&j                  |«      dk(  sŒ‰j                  |«      €Œ0 ‰*‰|   Ž }|r|dz  dk(  sJ ‚|dz  }n|dz  }|dk(  s||k  sŒZ|}d}‰|   }Œd ‰!D ]4  }‰"|   �Œ	‰&j                  |«      dk(  sŒ|dk(  s	‰!|   |k  sŒ,‰!|   }d}|}Œ6 |dk(  r)‰sJ ‚d}t#        dt        ‰#j                  «       «      «      }‰$D ]L  }‰&j                  ‰%|   «      dk(  r‰#|xx   |z  cc<   Œ(‰&j                  ‰%|   «      dk(  sŒ@‰#|xx   |z  cc<   ŒN ‰!D ]L  }‰"|   �Œ	‰&j                  |«      dk(  r‰!|xx   |z  cc<   Œ+‰&j                  |«      dk(  sŒ@‰!|xx   |z  cc<   ŒN |dk(  rn~|dk(  r2|\  }}‰&‰%|      dk(  sJ ‚dx‰||f<   ‰||f<   ‰)j%                  |«       nE|dk(  r2|\  }}dx‰||f<   ‰||f<   ‰&‰%|      dk(  sJ ‚‰)j%                  |«       n|dk(  r	 ||d«       �Œã‰(D ]  }‰(‰(|      |k(  rŒJ ‚ |snRt        ‰!j'                  «       «      D ]4  }|‰!vrŒ‰"|   �Œ‰&j                  |«      dk(  sŒ#‰!|   dk(  sŒ, ||d«       Œ6 �ŒÍ|r |«        t)        ‰(«      S )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                   ó   — e Zd ZdZy)ú#max_weight_matching.<locals>.NoNodez-Dummy value which is different from any node.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r6   r   r   ÚNoNoderE   Š  s   „ Ú;r   rJ   c                   ó$   •— e Zd ZdZg d¢Zˆ fd„Zy)ú$max_weight_matching.<locals>.Blossomz7Representation of a non-trivial blossom or sub-blossom.)Úchildsr   Úmybestedgesc              3   ó®   •K  — g | j                   ¢}|r@|j                  «       }t        |‰«      r|j                  |j                   «       n|–— |rŒ?y y ­wr5   )rM   Úpopr'   Úextend)ÚselfÚstackÚtÚBlossoms      €r   Úleavesz+max_weight_matching.<locals>.Blossom.leavesŸ  sF   øè ø€ Ø"�d—k‘k�NˆEÙØ—I‘I“K�Ü˜a Ô)Ø—L‘L §¡Õ*à’Gô ùs   ƒAAÁAN)rF   rG   rH   rI   Ú	__slots__rV   )rU   s   €r   rU   rL   �  s   ø„ ÙEâ6ˆ	õ	r   rU   r   T©r2   r1   ú')ÚintÚlongNc                 óR   •— ‰|    ‰|   z   d‰|    |   j                  ‰d«      z  z
  S )Nr"   r1   )Úget)r   r9   r   Údualvarr-   s     €€€r   Úslackz"max_weight_matching.<locals>.slackü  s3   ø€ Ø�q‰z˜G A™JÑ&¨¨Q¨q©T°!©W¯[©[¸ÀÓ-CÑ)CÑCÐCr   c                 óh  •	— ‰	|    }‰
j                  | «      €‰
j                  |«      �J ‚|x‰
| <   ‰
|<   |�|| fx‰| <   ‰|<   n
d x‰| <   ‰|<   d x‰| <   ‰|<   |dk(  r>t        |‰«      r ‰j                  |j                  «       «       y ‰j	                  |«       y |dk(  r‰|   } ‰‰|   d|«       y y )Nr1   r"   )r]   r'   rQ   rV   Úappend)r9   rT   r   ÚbÚbaserU   ÚassignLabelÚbestedgeÚblossombaseÚ	inblossomÚlabelÚ	labeledgeÚmateÚqueues        €€€€€€€€€r   rd   z(max_weight_matching.<locals>.assignLabel  sÓ   ø€ Ø�a‰LˆØ�y‰y˜‹|Ð#¨¯	©	°!«Ð(<Ð<Ð<ØÐˆˆa‰�5˜‘8Øˆ=Ø+,¨a¨&Ð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                 ó6  •— g }‰}| ‰urƒ‰|    }‰|   dz  r‰|   }np‰|   dk(  sJ ‚|j                  |«       d‰|<   ‰	|   €‰|   ‰
vsJ ‚‰} n2‰	|   d   ‰
‰|      k(  sJ ‚‰	|   d   } ‰|    }‰|   dk(  sJ ‚‰	|   d   } |‰ur|| }} | ‰urŒƒ|D ]  }d‰|<   Œ	 |S )Né   r1   é   r   r"   )ra   )r   r9   Úpathrc   rb   rJ   rf   rg   rh   ri   rj   s        €€€€€€r   ÚscanBlossomz(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                 ó¼  •— ‰|    }‰|   }‰|   } ‰«       }| ‰|<   d ‰|<   |‰|<   g x|_         }||fgx|_        }||k7  r`|‰|<   |j                  |«       |j                  ‰|   «       ‰|   dk(  s‰|   dk(  r‰|   d   ‰‰|      k(  sJ ‚‰|   d   }‰|   }||k7  rŒ`|j                  |«       |j                  «        |j                  «        ||k7  rk|‰|<   |j                  |«       |j                  ‰|   d   ‰|   d   f«       ‰|   dk(  s‰|   dk(  r‰|   d   ‰‰|      k(  sJ ‚‰|   d   }‰|   }||k7  rŒk‰|   dk(  sJ ‚d‰|<   ‰|   ‰|<   d‰|<   |j	                  «       D ]#  }‰‰|      dk(  r‰j                  |«       |‰|<   Œ% i }	|D ]ë  }t        |‰«      r^|j                  �|j                  }
d |_        nd|j	                  «       D ��cg c]"  }‰j                  |«      D ]  }||k7  sŒ	||f‘Œ Œ$ }
}}n&‰j                  |«      D �cg c]  }||k7  sŒ	||f‘Œ }
}|
D ]O  }|\  }}‰|   |k(  r||}}‰|   }||k7  sŒ‰j                  |«      dk(  sŒ4||	vs ‰||«       ‰|	|   Ž k  sŒK||	|<   ŒQ d ‰|<   Œí t        |	j                  «       «      |_        d }d ‰|<   |j                  D ]  } ‰|Ž }|�|k  sŒ|}|}Œ |‰|<   y c c}}w c c}w )Nr"   r1   r   )rM   r   ra   ÚreverserV   r'   rN   Ú	neighborsr]   ÚlistÚvalues)rc   r   r9   ÚbbÚbvÚbwrb   ro   ÚedgsÚ
bestedgetoÚnblistÚkÚiÚjÚbjÚ
mybestedgeÚkslackÚmybestslackrU   r   re   rf   ÚblossomdualÚblossomparentrg   rh   ri   rj   rk   r_   s                     €€€€€€€€€€€€r   Ú
addBlossomz'max_weight_matching.<locals>.addBlossom?  s£  ø€ Ø�t‰_ˆØ�q‰\ˆØ�q‰\ˆá‹IˆØˆ�A‰Øˆ�aÑØˆ�bÑàÐˆŒ�4Ø˜a˜&˜Ð!ˆŒ�$à�BŠhà !ˆM˜"ÑØ�K‰K˜ŒOØ�K‰K˜	 "™Ô&Ø˜‘9 ’>Ø�b‘	˜Q’ 9¨R¡=°Ñ#3°t¸KÈ¹OÑ7LÒ#Lðð ð ˜"‘˜aÑ ˆAØ˜1‘ˆBð �B‹hð 	�‰�BŒØ�‰ŒØ�‰Œà�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ð �B‹hð �R‰y˜AŠ~Ðˆ~Øˆˆa‰Ø  ‘}ˆ	�!‰àˆ�A‰à—‘“ò 	ˆAØ�Y˜q‘\Ñ" aÒ'ð —‘˜Q”ØˆI�aŠLð	ð ˆ
Øò 	 ˆBÜ˜"˜gÔ&Ø—>‘>Ð-àŸ^™^�Fà%)�B•Nð
 )+¯	©	«÷Ø#$¸Q¿[¹[È»^òØ89ÈqÐTUËv˜˜AšðØð�Fò ð ,-¯;©;°r«?ÖF a¸bÀA»g˜2˜qš'ÐF�ÐFØò 
'�Ø‘��AØ˜Q‘< 1Ò$Ø˜a�q�AØ˜q‘\�à˜!“GØŸ	™	 "›¨Ó*Ø JÑ.±5¸¸A³;ÁÈ
ÐSUÉÐAWÓ3Wà%&�J˜r’Nð
'ð  ˆH�RŠLð7	 ô8 ˜Z×.Ñ.Ó0Ó1ˆŒàˆ
Øˆ�‰Ø—‘ò 	%ˆAÙ˜A�YˆFØÐ! V¨kÓ%9Ø�
Ø$‘ð		%ð
 !ˆ�Šùó7ùò Gs   ÇKÇ9KÈ
KÈ#Kc                 ó®   •— ˆˆˆˆ	ˆ
ˆˆˆˆˆˆfd„} || |«      g}|r9|d   }|D ]  }|j                   |||«      «        n |j                  «        |rŒ8y y )Nc              3   ó8  •K  — | j                   D ]B  }d ‰|<   t        |‰«      r*|r‰|   dk(  r|–— Œ#|j                  «       D ]  }|‰|<   Œ	 Œ>|‰|<   ŒD |�s‰j                  | «      dk(  �rí‰‰|    d      }| j                   j	                  |«      }|dz  r|t        | j                   «      z  }d}nd}‰|    \  }}|dk7  rš|dk(  r| j                  |   \  }}	n| j                  |dz
     \  }	}d ‰|<   d ‰|	<    ‰|d|«       dx‰||	f<   ‰|	|f<   ||z  }|dk(  r| j                  |   \  }}n| j                  |dz
     \  }}dx‰||f<   ‰||f<   ||z  }|dk7  rŒš| j                   |   }
dx‰|<   ‰|
<   ||fx‰|<   ‰|
<   d ‰|
<   ||z  }| j                   |   |k7  r½| j                   |   }‰j                  |«      dk(  r||z  }Œ;t        |‰«      r)|j                  «       D ]  }‰j                  |«      sŒ n n|}‰j                  |«      r4‰|   dk(  sJ ‚‰|   |k(  sJ ‚d ‰|<   d ‰‰‰|      <    ‰|d‰|   d   «       ||z  }| j                   |   |k7  rŒ½‰j                  | d «       ‰j                  | d «       ‰j                  | d «       ‰| = ‰| = ‰| = y ­w)Nr   r"   r1   éÿÿÿÿT)rM   r'   rV   r]   Úindexr)   r   rP   )rb   ÚendstageÚsr   Ú
entrychildr~   Újstepr9   ÚpÚqrx   rw   rU   Ú	allowedgerd   re   rf   rƒ   r„   rg   rh   ri   rj   s               €€€€€€€€€€€r   Ú_recursez<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Ø˜1’fà ’zØ Ÿw™w q™z™˜™1à Ÿw™w q¨1¡u™~™˜˜1Ø#�E˜!‘HØ#�E˜!‘HÙ  1 aÔ(à<@Ð@�I˜q !˜fÑ%¨	°1°a°&Ñ(9Ø˜‘J�AØ ’zØ Ÿw™w q™z™˜™1à Ÿw™w q¨1¡u™~™˜˜1à<@Ð@�I˜q !˜fÑ%¨	°1°a°&Ñ(9Ø˜‘J�Að% ˜1“fð* —X‘X˜a‘[�Ø'(Ð(��a‘˜5 ™9Ø01°1¨vÐ5�	˜!‘˜y¨™}Ø#�˜‘à�U‘
�Ø—h‘h˜q‘k ZÒ/ð Ÿ™ !™�BØ—y‘y “}¨Ò)ð ˜U™
˜Ø Ü! " 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JÅBJÇ7A"JÉA Jrˆ   ©ra   rP   )rb   rŠ   r‘   rS   Útopr‹   rU   r�   rd   re   rf   rƒ   r„   rg   rh   ri   rj   s         €€€€€€€€€€€r   ÚexpandBlossomz*max_weight_matching.<locals>.expandBlossomž  sb   ø€ ÷[	ö [	ñD ˜!˜XÓ&Ð'ˆÙØ˜‘)ˆCØò �Ø—‘™X a¨Ó2Ô3Ùðð —	‘	”ô r   c                 ó˜   •— ˆˆˆˆ	fd„} || |«      g}|r5|d   }|D ]  }|j                   ||Ž «        n |j                  «        |rŒ4y y )Nc              3   óÊ  •K  — |}‰
|   | k7  r‰
|   }‰
|   | k7  rŒt        |‰«      r||f–— | j                  j                  |«      x}}|dz  r|t        | j                  «      z  }d}nd}|dk7  r‰||z  }| j                  |   }|dk(  r| j                  |   \  }}n| j                  |dz
     \  }}t        |‰«      r||f–— ||z  }| j                  |   }t        |‰«      r||f–— |‰|<   |‰|<   |dk7  rŒ‰| j                  |d  | j                  d | z   | _        | j                  |d  | j                  d | z   | _        ‰	| j                  d      ‰	| <   ‰	|    |k(  sJ ‚y ­w)Nr1   rˆ   r   )r'   rM   r‰   r)   r   )rb   r   rT   r}   r~   r�   r9   ÚxrU   rf   r„   rj   s           €€€€r   r‘   z=max_weight_matching.<locals>.augmentBlossom.<locals>._recurse  s�  øè ø€ ð ˆAØ Ñ" aÒ'Ø! !Ñ$�ð   Ñ" aÓ'ô ˜!˜WÔ%Ø˜!�f’à—H‘H—N‘N 1Ó%Ð%ˆA�Ø�1Šuà”S˜Ÿ™“]Ñ"�Ø‘ð �à�q’&à�U‘
�Ø—H‘H˜Q‘K�Ø˜A’:ØŸ7™7 1™:‘D�A‘qàŸ7™7 1 q¡5™>‘D�A�qÜ˜a Ô)Ø˜a˜&’Là�U‘
�Ø—H‘H˜Q‘K�Ü˜a Ô)Ø˜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   ƒE#œCE#Ã;A(E#rˆ   r’   )
rb   r   r‘   rS   r“   ÚargsrU   rf   r„   rj   s
         €€€€r   ÚaugmentBlossomz+max_weight_matching.<locals>.augmentBlossom  sW   ø€ ÷)	'ñ` ˜!˜Q“Ð ˆÙØ˜‘)ˆCØò �Ø—‘™X t˜_Ô-Ùðð —	‘	”ô r   c                 óJ  •— | |f|| ffD ]—  \  }}	 ‰
|   }‰|   dk(  sJ ‚‰|   €‰	|   ‰vs‰|   d   ‰‰	|      k(  sJ ‚t        |‰«      r	 ‰||«       |‰|<   ‰|   €ŒU‰|   d   }‰
|   }‰|   dk(  sJ ‚‰|   \  }}‰	|   |k(  sJ ‚t        |‰«      r	 ‰||«       |‰|<   Œ’ y )Nr1   r   r"   )r'   )r   r9   r‹   r~   ÚbsrT   ÚbtrU   r™   rf   rg   rh   ri   rj   s          €€€€€€€r   ÚaugmentMatchingz,max_weight_matching.<locals>.augmentMatchingS  s  ø€ Ø˜�V˜a ˜VÐ$ò 	‰DˆAˆqð Ø˜q‘\�Ø˜R‘y A’~Ð%�~Ø! "™Ð-°+¸b±/ÈÑ2MØ˜b‘M !Ñ$¨¨[¸©_Ñ(=Ò=ðð ô ˜b 'Ô*Ù" 2 qÔ)à��Q‘à˜R‘=Ð(àØ˜b‘M !Ñ$�Ø˜q‘\�Ø˜R‘y A’~Ð%�~à  ‘}‘��1à" 2‘¨!Ò+Ð+Ð+Ü˜b 'Ô*Ù" 2 qÔ)à��Q‘ð3 ñ		r   c                  ó,  •— ‰r%t        dt        ‰j                  «       «       «      } nd} t        ‰j                  «       «      | z   dk\  sJ ‚t        ‰«      dk(  st        ‰j                  «       «      dk\  sJ ‚‰j	                  d¬«      D �]  \  }}}|j                  ‰d«      }||k(  rŒ ‰|   ‰|   z   d|z  z
  }|g}|g}‰|d      � |j                  ‰|d      «       ‰|d      �Œ ‰|d      � |j                  ‰|d      «       ‰|d      �Œ |j                  «        |j                  «        t        ||«      D ]  \  }}	||	k7  r n|d‰|   z  z  }Œ |dk\  sJ ‚‰j                  |«      |k(  s‰j                  |«      |k(  sŒý‰|   |k(  r‰|   |k(  sJ ‚|dk(  r�ŒJ ‚ ‰D ]  }
|
‰v rŒ‰|
   | z   dk(  rŒJ ‚ ‰D ]T  }‰|   dkD  sŒt        |j                  «      dz  dk(  sJ ‚|j                  dd d…   D ]  \  }}‰|   |k(  r	‰|   |k(  rŒJ ‚ ŒV y )Nr   TrX   r1   r"   rˆ   )	r>   Úminru   r)   r   r]   ra   rr   Úzip)Úvdualoffsetr}   r~   ÚdÚwtr‹   Ú	iblossomsÚ	jblossomsÚbir   r   rb   r   rƒ   r„   r^   Úgnodesrj   r0   r-   s               €€€€€€€€r   ÚverifyOptimumz*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ˆq�!Ø—‘�v˜qÓ!ˆBØ�AŠvØØ˜‘
˜W Q™ZÑ'¨!¨b©&Ñ0ˆAØ˜ˆIØ˜ˆIØ 	¨"¡Ñ.Ð:Ø× Ñ  ¨y¸©}Ñ!=Ô>ð   	¨"¡Ñ.Ñ:à 	¨"¡Ñ.Ð:Ø× Ñ  ¨y¸©}Ñ!=Ô>ð   	¨"¡Ñ.Ñ:à×ÑÔØ×ÑÔÜ˜i¨Ó3ò )‘��BØ˜’8ÙØ�Q˜ R™Ñ(Ñ(‘ð)ð ˜’6ˆM�6Ø�x‰x˜‹{˜aÒ 4§8¡8¨A£;°!Ó#3Ø˜A‘w !’|¨¨Q©°1ªÐ4Ð4Ø˜A”v��vð)	ð, ò 	@ˆAØ˜’I '¨!¡*¨{Ñ":¸aÓ"?Ð?Ð?ð	@ð ò 	9ˆAØ˜1‰~ Ó!Ü˜1Ÿ7™7“| aÑ'¨1Ò,Ð,Ð,ØŸG™G A D q D™Mò 9‘D�A�qØ ™7 aš<¨D°©G°q«LÐ8Ð8ñ9ñ	9r   r"   rˆ   g       @é   rm   F)rt   r   r   r]   ÚstrÚtypeÚsplitr(   r    r   ÚclearrN   rP   rs   rŸ   ru   r   r>   ra   Úkeysr    )+r   r0   r-   Ú	maxweightÚ
allintegerr}   r~   r¢   r£   rp   r…   r”   r�   r¨   rb   r   Ú	augmentedr9   rw   rx   r�   rc   Ú	deltatypeÚdeltaÚ	deltaedgeÚdeltablossomrU   rJ   r�   rd   r™   re   rf   rƒ   r„   r^   r§   rg   rh   ri   rj   rk   r_   s+   ```                       @@@@@@@@@@@@@@@@@r   r	   r	   >  s�  ÿÿû€ ÷X<ñ <÷ó ô8 �!‹W€FÙÜ‹uˆð €IØ€JØ—7‘7 �7Ó%ò U‰ˆˆ1ˆaØ�U‰U�6˜1ÓˆØ�Š6�b˜9’nØˆIØÒT¤S¬¨b«£]×%8Ñ%8¸Ó%=¸aÑ%@ÀOÐ%S‰
ð	Uð €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›ó 41�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›¨!Ò+ð $Ÿ<™<¨Ó+Ð3°vÁÀxÐPRÁ|Ð@TÓ7TØ,-¨q¨6˜H RšLØŸ™ 1›Ò-ð $Ÿ<™<¨›?Ð2°f¹uÀhÈqÁkÐ?RÔ6RØ+,¨a¨&˜H Q›Kði41ñ £	ñx Ùð ˆIØ/3Ð3ˆEÐ3�I ñ "Ø�	Ü˜GŸN™NÓ,Ó-�ð —W‘W“Yò 0�Ø—9‘9˜Y q™\Ó*Ñ2°x·|±|ÀA³Ñ7RÙ˜x¨™{Ð+�AØ  B’¨!¨e«)Ø !˜Ø$%˜	Ø$,¨Q¡K™	ð0ð #ò 0�à! !Ñ$Ñ,ØŸ	™	 !›¨Ó)Ø Ÿ™ Q›Ñ3á" H¨Q¡KÐ0�FÙ!Ø &¨¡
¨qÒ0Ð0Ð0Ø" a™K™à" S™L˜Ø  B’¨!¨e«)Ø !˜Ø$%˜	Ø$,¨Q¡K™	ð0ð$ !ò %�à! !Ñ$Ñ,ØŸ	™	 !›¨Ó)Ø" 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ð(ð !ò 0�Ø  Ñ#Ñ+Ø—y‘y “| qÒ(à# A›¨%Ñ/œØŸ™ 1›¨Ó*à# A›¨%Ñ/œð0ð ˜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-   )rI   Ú	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   