
    h                         S r SSKJr  SSKrSS/r\R                  " SS0SS9SS	 j5       r\R                  SS
 j5       rg)aY  Routines to find the boundary of a set of nodes.

An edge boundary is a set of edges, each of which has exactly one
endpoint in a given set of nodes (or, in the case of directed graphs,
the set of edges whose source node is in the set).

A node boundary of a set *S* of nodes is the set of (out-)neighbors of
nodes in *S* that are outside *S*.

    )chainNedge_boundarynode_boundarydatadefault)
edge_attrspreserve_edge_attrsc                    ^^	 U Vs1 s H  ofU ;   d  M
  UiM     snmU R                  5       (       a  U R                  TX4US9nOU R                  TX5S9nUc  U4S jU 5       $ [        U5      m	UU	4S jU 5       $ s  snf )a  Returns the edge boundary of `nbunch1`.

The *edge boundary* of a set *S* with respect to a set *T* is the
set of edges (*u*, *v*) such that *u* is in *S* and *v* is in *T*.
If *T* is not specified, it is assumed to be the set of all nodes
not in *S*.

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

nbunch1 : iterable
    Iterable of nodes in the graph representing the set of nodes
    whose edge boundary will be returned. (This is the set *S* from
    the definition above.)

nbunch2 : iterable
    Iterable of nodes representing the target (or "exterior") set of
    nodes. (This is the set *T* from the definition above.) If not
    specified, this is assumed to be the set of all nodes in `G`
    not in `nbunch1`.

keys : bool
    This parameter has the same meaning as in
    :meth:`MultiGraph.edges`.

data : bool or object
    This parameter has the same meaning as in
    :meth:`MultiGraph.edges`.

default : object
    This parameter has the same meaning as in
    :meth:`MultiGraph.edges`.

Returns
-------
iterator
    An iterator over the edges in the boundary of `nbunch1` with
    respect to `nbunch2`. If `keys`, `data`, or `default`
    are specified and `G` is a multigraph, then edges are returned
    with keys and/or data, as in :meth:`MultiGraph.edges`.

Examples
--------
>>> G = nx.wheel_graph(6)

When nbunch2=None:

>>> list(nx.edge_boundary(G, (1, 3)))
[(1, 0), (1, 2), (1, 5), (3, 0), (3, 2), (3, 4)]

When nbunch2 is given:

>>> list(nx.edge_boundary(G, (1, 3), (2, 0)))
[(1, 0), (1, 2), (3, 0), (3, 2)]

Notes
-----
Any element of `nbunch` that is not in the graph `G` will be
ignored.

`nbunch1` and `nbunch2` are usually meant to be disjoint, but in
the interest of speed and generality, that is not required here.

)r   keysr   )r   r   c              3   V   >#    U  H  oS    T;   US   T;   -  (       d  M  Uv   M      g7fr      N ).0enset1s     N/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/boundary.py	<genexpr> edge_boundary.<locals>.<genexpr>e   s(     F5aqTU]qtu}$E5s   )	)c              3   x   >#    U  H/  nUS    T;   a	  US   T;   d  US   T;   d  M   US    T;   d  M+  Uv   M1     g7fr   r   )r   r   r   nset2s     r   r   r   g   sI      AaDEMadem1 	
CDQ45= 	
s   ::	:)is_multigraphedgesset)
Gnbunch1nbunch2r   r   r   nr   r   r   s
           @@r   r   r      s    F  *16Q*E 	DWED:
 F5FFLE # +s
   	A;A;c                    ^  U Vs1 s H  o3T ;   d  M
  UiM     nn[        [        R                  " U 4S jU 5       5      5      U-
  nUb  U[        U5      -  nU$ s  snf )a  Returns the node boundary of `nbunch1`.

The *node boundary* of a set *S* with respect to a set *T* is the
set of nodes *v* in *T* such that for some *u* in *S*, there is an
edge joining *u* to *v*. If *T* is not specified, it is assumed to
be the set of all nodes not in *S*.

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

nbunch1 : iterable
    Iterable of nodes in the graph representing the set of nodes
    whose node boundary will be returned. (This is the set *S* from
    the definition above.)

nbunch2 : iterable
    Iterable of nodes representing the target (or "exterior") set of
    nodes. (This is the set *T* from the definition above.) If not
    specified, this is assumed to be the set of all nodes in `G`
    not in `nbunch1`.

Returns
-------
set
    The node boundary of `nbunch1` with respect to `nbunch2`.

Examples
--------
>>> G = nx.wheel_graph(6)

When nbunch2=None:

>>> list(nx.node_boundary(G, (3, 4)))
[0, 2, 5]

When nbunch2 is given:

>>> list(nx.node_boundary(G, (3, 4), (0, 1, 5)))
[0, 5]

Notes
-----
Any element of `nbunch` that is not in the graph `G` will be
ignored.

`nbunch1` and `nbunch2` are usually meant to be disjoint, but in
the interest of speed and generality, that is not required here.

c              3   .   >#    U  H
  nTU   v   M     g 7fNr   )r   vr   s     r   r    node_boundary.<locals>.<genexpr>   s     !61!A$s   )r   r   from_iterable)r   r   r   r   r   bdys   `     r   r   r   n   s^    h  *16QE*
e!!!6!66
7%
?C s7|J +s
   	AA)NFFNr!   )	__doc__	itertoolsr   networkxnx__all___dispatchabler   r   r       r   <module>r-      s`   	  O
, fi0fMW NWt 9 9r,   