+
    �°³j³(  ã                   ó²  € R t ^ RIHt ^ RIt. ROt]P                  ! RR7      RR l4       t]P                  ! RR7      RR l4       t]P                  ! RR7      RR l4       t	]P                  ! RR7      RR l4       t
]P                  ! RR7      RR	 l4       t]P                  ! RR7      RR
 l4       t]P                  R 4       t]P                  R 4       tR# )z5Functions for finding and evaluating cuts in a graph.)ÚchainNÚweight)Ú
edge_attrsc                óÊ   € \         P                  ! WW#^R7      pV P                  4       '       d$   \        V\         P                  ! WW^R7      4      p\	        R V 4       4      # )aß  Returns the size of the cut between two sets of nodes.

A *cut* is a partition of the nodes of a graph into two sets. The
*cut size* is the sum of the weights of the edges "between" the two
sets of nodes.

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

S : collection
    A collection of nodes in `G`.

T : collection
    A collection of nodes in `G`. If not specified, this is taken to
    be the set complement of `S`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    Total weight of all edges from nodes in set `S` to nodes in
    set `T` (and, in the case of directed graphs, all edges from
    nodes in `T` to nodes in `S`).

Examples
--------
In the graph with two cliques joined by a single edges, the natural
bipartition of the graph into two blocks, one for each clique,
yields a cut of weight one:

>>> G = nx.barbell_graph(3, 0)
>>> S = {0, 1, 2}
>>> T = {3, 4, 5}
>>> nx.cut_size(G, S, T)
1

Each parallel edge in a multigraph is counted when determining the
cut size:

>>> G = nx.MultiGraph(["ab", "ab"])
>>> S = {"a"}
>>> T = {"b"}
>>> nx.cut_size(G, S, T)
2

Notes
-----
In a multigraph, the cut size is the total weight of edges including
multiplicity.

)ÚdataÚdefaultc              3   ó*   "  € T F	  w  rq3x € K  	  R # 5i©N© )Ú.0ÚuÚvr   s   &   ÚY/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/algorithms/cuts.pyÚ	<genexpr>Úcut_size.<locals>.<genexpr>R   s   é € Ð0©%™,˜! Œv«%ùó   ‚)ÚnxÚedge_boundaryÚis_directedr   Úsum)ÚGÚSÚTr   Úedgess   &&&& r   Úcut_sizer      sP   € ôr ×Ò˜Q 1¸1Ô=€EØ‡}�}‡‚Ü�eœR×-Ò-¨a°AÈAÔNÓOˆÜÑ0©%Ó0Ó0Ð0ó    c                ó�   € V P                  4       '       d   V P                  MV P                  p\        R V! WR7       4       4      # )a  Returns the volume of a set of nodes.

The *volume* of a set *S* is the sum of the (out-)degrees of nodes
in *S* (taking into account parallel edges in multigraphs). [1]

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

S : collection
    A collection of nodes in `G`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    The volume of the set of nodes represented by `S` in the graph
    `G`.

See also
--------
conductance
cut_size
edge_expansion
edge_boundary
normalized_cut_size

References
----------
.. [1] David Gleich.
       *Hierarchical Directed Spectral Graph Partitioning*.
       <https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202005%20-%20hierarchical%20directed%20spectral.pdf>

c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir	   r
   )r   r   Úds   &  r   r   Úvolume.<locals>.<genexpr>}   s   é € Ð6Ñ5‘T�Q�qÓ5ùr   ©r   )r   Ú
out_degreeÚdegreer   )r   r   r   r"   s   &&& r   Úvolumer#   U   s4   € ðN Ÿ]™]Ÿ_š_ˆQ�\Š\°!·(±(€FÜÑ6™V AÕ5Ó6Ó6Ð6r   c                óÊ   € Vf   \        V 4      \        V4      ,
          p\        WW#R7      p\        WVR7      p\        WVR7      pV^V,          ^V,          ,           ,          # )a‚  Returns the normalized size of the cut between two sets of nodes.

The *normalized cut size* is the cut size times the sum of the
reciprocal sizes of the volumes of the two sets. [1]

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

S : collection
    A collection of nodes in `G`.

T : collection
    A collection of nodes in `G`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    The normalized cut size between the two sets `S` and `T`.

Notes
-----
In a multigraph, the cut size is the total weight of edges including
multiplicity.

See also
--------
conductance
cut_size
edge_expansion
volume

References
----------
.. [1] David Gleich.
       *Hierarchical Directed Spectral Graph Partitioning*.
       <https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202005%20-%20hierarchical%20directed%20spectral.pdf>

©r   r   r    )Úsetr   r#   ©r   r   r   r   Únum_cut_edgesÚvolume_SÚvolume_Ts   &&&&   r   Únormalized_cut_sizer+   €   sW   € ðZ 	‚yÜ�‹F”S˜“V�OˆÜ˜Q QÔ6€MÜ�a 6Ô*€HÜ�a 6Ô*€HØ˜Q �\¨a°(­lÕ;Õ<Ð<r   c                ó²   € Vf   \        V 4      \        V4      ,
          p\        WW#R7      p\        WVR7      p\        WVR7      pV\        WV4      ,          # )a   Returns the conductance of two sets of nodes.

The *conductance* is the quotient of the cut size and the smaller of
the volumes of the two sets. [1]

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

S : collection
    A collection of nodes in `G`.

T : collection
    A collection of nodes in `G`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    The conductance between the two sets `S` and `T`.

See also
--------
cut_size
edge_expansion
normalized_cut_size
volume

References
----------
.. [1] David Gleich.
       *Hierarchical Directed Spectral Graph Partitioning*.
       <https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202005%20-%20hierarchical%20directed%20spectral.pdf>

r    )r&   r   r#   Úminr'   s   &&&&   r   Úconductancer.   µ   sO   € ðP 	‚yÜ�‹F”S˜“V�OˆÜ˜Q 1Ô4€MÜ�a 6Ô*€HÜ�a 6Ô*€HØœ3˜xÓ2Õ2Ð2r   c                ó¤   € Vf   \        V 4      \        V4      ,
          p\        WW#R7      pV\        \        V4      \        V4      4      ,          # )a5  Returns the edge expansion between two node sets.

The *edge expansion* is the quotient of the cut size and the smaller
of the cardinalities of the two sets. [1]

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

S : collection
    A collection of nodes in `G`.

T : collection
    A collection of nodes in `G`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    The edge expansion between the two sets `S` and `T`.

See also
--------
boundary_expansion
mixing_expansion
node_expansion

References
----------
.. [1] Fan Chung.
       *Spectral Graph Theory*.
       (CBMS Regional Conference Series in Mathematics, No. 92),
       American Mathematical Society, 1997, ISBN 0-8218-0315-8
       <http://www.math.ucsd.edu/~fan/research/revised.html>

r%   )r&   r   r-   Úlen)r   r   r   r   r(   s   &&&& r   Úedge_expansionr1   å   sA   € ðR 	‚yÜ�‹F”S˜“V�OˆÜ˜Q QÔ6€MØœ3œs 1›v¤s¨1£vÓ.Õ.Ð.r   c                ó\   € \        WW#R7      pV P                  4       pV^V,          ,          # )uÿ  Returns the mixing expansion between two node sets.

The *mixing expansion* is the quotient of the cut size and twice the
number of edges in the graph. [1]

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

S : collection
    A collection of nodes in `G`.

T : collection
    A collection of nodes in `G`.

weight : object
    Edge attribute key to use as weight. If not specified, edges
    have weight one.

Returns
-------
number
    The mixing expansion between the two sets `S` and `T`.

See also
--------
boundary_expansion
edge_expansion
node_expansion

References
----------
.. [1] Vadhan, Salil P.
       "Pseudorandomness."
       *Foundations and Trends
       in Theoretical Computer Science* 7.1â€“3 (2011): 1â€“336.
       <https://doi.org/10.1561/0400000010>

r%   )r   Únumber_of_edges)r   r   r   r   r(   Únum_total_edgess   &&&&  r   Úmixing_expansionr5     s/   € ôR ˜Q QÔ6€MØ×'Ñ'Ó)€OØ˜A Õ/Õ0Ð0r   c                óŒ   a € \        \        P                  ! V 3R lV 4       4      4      p\        V4      \        V4      ,          # )uQ  Returns the node expansion of the set `S`.

The *node expansion* is the quotient of the size of the node
boundary of *S* and the cardinality of *S*. [1]

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

S : collection
    A collection of nodes in `G`.

Returns
-------
number
    The node expansion of the set `S`.

See also
--------
boundary_expansion
edge_expansion
mixing_expansion

References
----------
.. [1] Vadhan, Salil P.
       "Pseudorandomness."
       *Foundations and Trends
       in Theoretical Computer Science* 7.1â€“3 (2011): 1â€“336.
       <https://doi.org/10.1561/0400000010>

c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir	   )Ú	neighbors)r   r   r   s   & €r   r   Ú!node_expansion.<locals>.<genexpr>f  s   øé € Ð*EÁ1¸a¨1¯;©;°q¯>¨>Ã1ùs   ƒ!)r&   r   Úfrom_iterabler0   )r   r   Úneighborhoods   f& r   Únode_expansionr<   D  s5   ø€ ôD ”u×*Ò*Ô*EÁ1Ó*EÓEÓF€LÜˆ|Óœs 1›vÕ%Ð%r   c                ó`   € \        \        P                  ! W4      4      \        V4      ,          # )u[  Returns the boundary expansion of the set `S`.

The *boundary expansion* of a set `S` is the ratio between the size of its
node boundary and the cardinality of the set itself [1]_ .

Parameters
----------
G : NetworkX graph
    The input graph.

S : collection
    A collection of nodes in `G`.

Returns
-------
number
    The boundary expansion ratio: size of node boundary / size of `S`.

Examples
--------
The node boundary is {2, 3} (size 2), divided by ``|S|=2``:

>>> G = nx.cycle_graph(4)
>>> S = {0, 1}
>>> nx.boundary_expansion(G, S)
1.0

For disconnected sets, e.g. here where the node boundary is ``{1, 3, 5}``:

>>> G = nx.cycle_graph(6)
>>> S = {0, 2, 4}
>>> nx.boundary_expansion(G, S)
1.0

See also
--------
:func:`~networkx.algorithms.boundary.node_boundary`
edge_expansion
mixing_expansion
node_expansion

Notes
-----
The node boundary is defined as all nodes not in `S` that are adjacent to
nodes in `S`.

References
----------
.. [1] Vadhan, Salil P.
   "Pseudorandomness." *Foundations and Trends in Theoretical Computer Science*
   7.1â€“3 (2011): 1â€“336. <https://doi.org/10.1561/0400000010>
)r0   r   Únode_boundary)r   r   s   &&r   Úboundary_expansionr?   j  s$   € ôl Œr×Ò Ó%Ó&¬¨Q«Õ/Ð/r   )r?   r.   r   r1   r5   r<   r+   r#   )NNr	   )Ú__doc__Ú	itertoolsr   Únetworkxr   Ú__all__Ú_dispatchabler   r#   r+   r.   r1   r5   r<   r?   r
   r   r   Ú<module>rE      s
  ðÙ ;å ã ò	€ð ×Ò˜XÔ&ó;1ó 'ð;1ð| ×Ò˜XÔ&ó'7ó 'ð'7ðT ×Ò˜XÔ&ó1=ó 'ð1=ðh ×Ò˜XÔ&ó,3ó 'ð,3ð^ ×Ò˜XÔ&ó+/ó 'ð+/ð\ ×Ò˜XÔ&ó*1ó 'ð*1ð^ ×Ññ"&ó ð"&ðJ ×Ññ50ó ò50r   