
    h4                     2   S r SSKJr  SSKJrJr  SSKr/ SQr " S S\\5      r	 " S S	\5      r
 " S
 S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S  S!\5      r " S" S#\5      r " S$ S%\5      r " S& S'\5      r " S( S)\\\5      r " S* S+\5      r " S, S-\5      r " S. S/\5      r " S0 S1\5      r " S2 S3\5      rg)4a  
View Classes provide node, edge and degree "views" of a graph.

Views for nodes, edges and degree are provided for all base graph classes.
A view means a read-only object that is quick to create, automatically
updated when the graph changes, and provides basic access like `n in V`,
`for n in V`, `V[n]` and sometimes set operations.

The views are read-only iterable containers that are updated as the
graph is updated. As with dicts, the graph should not be updated
while iterating through the view. Views can be iterated multiple times.

Edge and Node views also allow data attribute lookup.
The resulting attribute dict is writable as `G.edges[3, 4]['color']='red'`
Degree views allow lookup of degree values for single nodes.
Weighted degree is supported with the `weight` argument.

NodeView
========

    `V = G.nodes` (or `V = G.nodes()`) allows `len(V)`, `n in V`, set
    operations e.g. "G.nodes & H.nodes", and `dd = G.nodes[n]`, where
    `dd` is the node data dict. Iteration is over the nodes by default.

NodeDataView
============

    To iterate over (node, data) pairs, use arguments to `G.nodes()`
    to create a DataView e.g. `DV = G.nodes(data='color', default='red')`.
    The DataView iterates as `for n, color in DV` and allows
    `(n, 'red') in DV`. Using `DV = G.nodes(data=True)`, the DataViews
    use the full datadict in writeable form also allowing contain testing as
    `(n, {'color': 'red'}) in VD`. DataViews allow set operations when
    data attributes are hashable.

DegreeView
==========

    `V = G.degree` allows iteration over (node, degree) pairs as well
    as lookup: `deg=V[n]`. There are many flavors of DegreeView
    for In/Out/Directed/Multi. For Directed Graphs, `G.degree`
    counts both in and out going edges. `G.out_degree` and
    `G.in_degree` count only specific directions.
    Weighted degree using edge data attributes is provide via
    `V = G.degree(weight='attr_name')` where any string with the
    attribute name can be used. `weight=None` is the default.
    No set operations are implemented for degrees, use NodeView.

    The argument `nbunch` restricts iteration to nodes in nbunch.
    The DegreeView can still lookup any node even if nbunch is specified.

EdgeView
========

    `V = G.edges` or `V = G.edges()` allows iteration over edges as well as
    `e in V`, set operations and edge data lookup `dd = G.edges[2, 3]`.
    Iteration is over 2-tuples `(u, v)` for Graph/DiGraph. For multigraphs
    edges 3-tuples `(u, v, key)` are the default but 2-tuples can be obtained
    via `V = G.edges(keys=False)`.

    Set operations for directed graphs treat the edges as a set of 2-tuples.
    For undirected graphs, 2-tuples are not a unique representation of edges.
    So long as the set being compared to contains unique representations
    of its edges, the set operations will act as expected. If the other
    set contains both `(0, 1)` and `(1, 0)` however, the result of set
    operations may contain both representations of the same edge.

EdgeDataView
============

    Edge data can be reported using an EdgeDataView typically created
    by calling an EdgeView: `DV = G.edges(data='weight', default=1)`.
    The EdgeDataView allows iteration over edge tuples, membership checking
    but no set operations.

    Iteration depends on `data` and `default` and for multigraph `keys`
    If `data is False` (the default) then iterate over 2-tuples `(u, v)`.
    If `data is True` iterate over 3-tuples `(u, v, datadict)`.
    Otherwise iterate over `(u, v, datadict.get(data, default))`.
    For Multigraphs, if `keys is True`, replace `u, v` with `u, v, key`
    to create 3-tuples and 4-tuples.

    The argument `nbunch` restricts edges to those incident to nodes in nbunch.
    )ABC)MappingSetN)NodeViewNodeDataViewEdgeViewOutEdgeView
InEdgeViewEdgeDataViewOutEdgeDataViewInEdgeDataViewMultiEdgeViewOutMultiEdgeViewInMultiEdgeViewMultiEdgeDataViewOutMultiEdgeDataViewInMultiEdgeDataView
DegreeViewDiDegreeViewInDegreeViewOutDegreeViewMultiDegreeViewDiMultiDegreeViewInMultiDegreeViewOutMultiDegreeViewc                   v    \ rS rSrSrSrS rS rS rS r	S r
S	 rS
 r\S 5       rSS jrSS jrS rS rSrg)r   v   a)  A NodeView class to act as G.nodes for a NetworkX Graph

Set operations act on the nodes without considering data.
Iteration is over nodes. Node data can be looked up like a dict.
Use NodeDataView to iterate over node data or to specify a data
attribute for lookup. NodeDataView is created by calling the NodeView.

Parameters
----------
graph : NetworkX graph-like class

Examples
--------
>>> G = nx.path_graph(3)
>>> NV = G.nodes()
>>> 2 in NV
True
>>> for n in NV:
...     print(n)
0
1
2
>>> assert NV & {1, 2, 3} == {1, 2}

>>> G.add_node(2, color="blue")
>>> NV[2]
{'color': 'blue'}
>>> G.add_node(8, color="red")
>>> NDV = G.nodes(data=True)
>>> (2, NV[2]) in NDV
True
>>> for n, dd in NDV:
...     print((n, dd.get("color", "aqua")))
(0, 'aqua')
(1, 'aqua')
(2, 'blue')
(8, 'red')
>>> NDV[2] == NV[2]
True

>>> NVdata = G.nodes(data="color", default="aqua")
>>> (2, NVdata[2]) in NVdata
True
>>> for n, dd in NVdata:
...     print((n, dd))
(0, 'aqua')
(1, 'aqua')
(2, 'blue')
(8, 'red')
>>> NVdata[2] == NV[2]  # NVdata gets 'color', NV gets datadict
False
_nodesc                     SU R                   0$ Nr   r   selfs    N/var/www/html/env/lib/python3.13/site-packages/networkx/classes/reportviews.py__getstate__NodeView.__getstate__   s    $++&&    c                     US   U l         g r!   r   r#   states     r$   __setstate__NodeView.__setstate__   s    Hor'   c                 &    UR                   U l        g N)_noder   )r#   graphs     r$   __init__NodeView.__init__   s    kkr'   c                 ,    [        U R                  5      $ r.   lenr   r"   s    r$   __len__NodeView.__len__       4;;r'   c                 ,    [        U R                  5      $ r.   )iterr   r"   s    r$   __iter__NodeView.__iter__   s    DKK  r'   c           
          [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eU R                  U   $ )Nz- does not support slicing, try list(G.nodes)[:])

isinstanceslicenxNetworkXErrortype__name__startstopstepr   r#   ns     r$   __getitem__NodeView.__getitem__   sl    a"":&&' (%%&WWIQqvvhaxqB  {{1~r'   c                     XR                   ;   $ r.   r   rI   s     r$   __contains__NodeView.__contains__   s    KKr'   c                     [        U5      $ r.   setclsits     r$   _from_iterableNodeView._from_iterable       2wr'   Nc                 <    USL a  U $ [        U R                  X5      $ NFr   r   r#   datadefaults      r$   __call__NodeView.__call__   s    5=KDKK77r'   c                 <    USL a  U $ [        U R                  X5      $ )a:  
Return a read-only view of node data.

Parameters
----------
data : bool or node data key, default=True
    If ``data=True`` (the default), return a `NodeDataView` object that
    maps each node to *all* of its attributes. `data` may also be an
    arbitrary key, in which case the `NodeDataView` maps each node to
    the value for the keyed attribute. In this case, if a node does
    not have the `data` attribute, the `default` value is used.
default : object, default=None
    The value used when a node does not have a specific attribute.

Returns
-------
NodeDataView
    The layout of the returned NodeDataView depends on the value of the
    `data` parameter.

Notes
-----
If ``data=False``, returns a `NodeView` object without data.

See Also
--------
NodeDataView

Examples
--------
>>> G = nx.Graph()
>>> G.add_nodes_from(
...     [
...         (0, {"color": "red", "weight": 10}),
...         (1, {"color": "blue"}),
...         (2, {"color": "yellow", "weight": 2}),
...     ]
... )

Accessing node data with ``data=True`` (the default) returns a
NodeDataView mapping each node to all of its attributes:

>>> G.nodes.data()
NodeDataView({0: {'color': 'red', 'weight': 10}, 1: {'color': 'blue'}, 2: {'color': 'yellow', 'weight': 2}})

If `data` represents  a key in the node attribute dict, a NodeDataView mapping
the nodes to the value for that specific key is returned:

>>> G.nodes.data("color")
NodeDataView({0: 'red', 1: 'blue', 2: 'yellow'}, data='color')

If a specific key is not found in an attribute dict, the value specified
by `default` is returned:

>>> G.nodes.data("weight", default=-999)
NodeDataView({0: 10, 1: -999, 2: 2}, data='weight')

Note that there is no check that the `data` key is in any of the
node attribute dictionaries:

>>> G.nodes.data("height")
NodeDataView({0: None, 1: None, 2: None}, data='height')
Fr[   r\   s      r$   r]   NodeView.data   s"    @ 5=KDKK77r'   c                 *    [        [        U 5      5      $ r.   strlistr"   s    r$   __str__NodeView.__str__      4:r'   c                 L    U R                   R                   S[        U 5       S3$ N())	__class__rE   tupler"   s    r$   __repr__NodeView.__repr__  s$    ..))*!E$K=::r'   FN)TN)rE   
__module____qualname____firstlineno____doc__	__slots__r%   r+   r1   r6   r;   rK   rN   classmethodrV   r_   r]   rg   rp   __static_attributes__ r'   r$   r   r   v   s\    3j I'&" !   8
B8H;r'   r   c                   f    \ rS rSrSrSrS rS rSS jr\	S 5       r
S	 rS
 rS rS rS rS rSrg)r   i  ae  A DataView class for nodes of a NetworkX Graph

The main use for this class is to iterate through node-data pairs.
The data can be the entire data-dictionary for each node, or it
can be a specific attribute (with default) for each node.
Set operations are enabled with NodeDataView, but don't work in
cases where the data is not hashable. Use with caution.
Typically, set operations on nodes use NodeView, not NodeDataView.
That is, they use `G.nodes` instead of `G.nodes(data='foo')`.

Parameters
==========
graph : NetworkX graph-like class
data : bool or string (default=False)
default : object (default=None)
r   _data_defaultc                 J    U R                   U R                  U R                  S.$ )Nr|   r|   r"   s    r$   r%   NodeDataView.__getstate__3  s    ++

VVr'   c                 @    US   U l         US   U l        US   U l        g )Nr   r}   r~   r|   r)   s     r$   r+   NodeDataView.__setstate__6  s$    Ho7^
j)r'   Nc                 (    Xl         X l        X0l        g r.   r|   )r#   nodedictr]   r^   s       r$   r1   NodeDataView.__init__;  s    
r'   c                      [        U5      $ ! [         a/  nS[        U5      ;   a  Sn[        [        U5      U-   5      Uee S nAff = f)N
unhashablez7 : Could be b/c data=True or your values are unhashable)rR   	TypeErrorre   )rT   rU   errmsgs       r$   rV   NodeDataView._from_iterable@  sI    	r7N 	s3x'OC3/S8		s   
 
A*AAc                 ,    [        U R                  5      $ r.   r4   r"   s    r$   r6   NodeDataView.__len__J  r8   r'   c                    ^ ^ T R                   mTSL a  [        T R                  5      $ TSL a#  [        T R                  R                  5       5      $ UU 4S jT R                  R                  5        5       $ )NFTc              3   Z   >#    U  H   u  pUTU;   a  UT   OTR                   4v   M"     g 7fr.   )r~   ).0rJ   ddr]   r#   s      r$   	<genexpr>(NodeDataView.__iter__.<locals>.<genexpr>S  s/      
, DBJ4DMM:,   (+)r}   r:   r   items)r#   r]   s   `@r$   r;   NodeDataView.__iter__M  s`    zz5=$$4<))+,,
**,
 	
r'   c                      XR                   ;   nUSL a  U$  Uu  pXR                   ;   =(       a    X   U:H  $ ! [         a#    Uu  pXR                   ;   =(       a    X   U:H  s $ f = f! [        [        4 a     gf = f)NTF)r   r   
ValueError)r#   rJ   node_inds       r$   rN   NodeDataView.__contains__X  s    	5;;&G d?N	DA KK0DGqL0  	5DA#414	5 :& 		s    8 A( *A%$A%(A;:A;c           
      J   [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eU R                  U   nU R                  nUSL d  USL a  U$ X2;   a  X#   $ U R                  $ )Nz4 does not support slicing, try list(G.nodes.data())[r>   r?   FT)r@   rA   rB   rC   rD   rE   rF   rG   rH   r   r}   r~   )r#   rJ   ddictr]   s       r$   rK   NodeDataView.__getitem__f  s    a"":&&' (,,-GG9AaffXQqvvhaI  Azz5=DDLL"mu{>>r'   c                 *    [        [        U 5      5      $ r.   rd   r"   s    r$   rg   NodeDataView.__str__r  ri   r'   c                     U R                   R                  nU R                  SL a  U S[        U 5       S3$ U R                  SL a  U S[	        U 5       S3$ U S[	        U 5       SU R                  < S3$ )NFrl   rm   Tz, data=)rn   rE   r}   ro   dict)r#   names     r$   rp   NodeDataView.__repr__u  sx    ~~&&::V1U4[M++::V1T$ZL**qdGDJJ>;;r'   )r}   r~   r   rr   )rE   rs   rt   ru   rv   rw   r%   r+   r1   rx   rV   r6   r;   rN   rK   rg   rp   ry   rz   r'   r$   r   r     sP    " 0IW*
 
   	
1
?<r'   r   c                   J    \ rS rSrSrSS jrSS jrS rS rS r	S	 r
S
 rSrg)r   i  a  A View class for degree of nodes in a NetworkX Graph

The functionality is like dict.items() with (node, degree) pairs.
Additional functionality includes read-only lookup of node degree,
and calling with optional features nbunch (for only a subset of nodes)
and weight (use edge weights to compute degree).

Parameters
==========
graph : NetworkX graph-like class
nbunch : node, container of nodes, or None meaning all nodes (default=None)
weight : bool or string (default=None)

Notes
-----
DegreeView can still lookup any node even if nbunch is specified.

Examples
--------
>>> G = nx.path_graph(3)
>>> DV = G.degree()
>>> assert DV[2] == 1
>>> assert sum(deg for n, deg in DV) == 4

>>> DVweight = G.degree(weight="span")
>>> G.add_edge(1, 2, span=34)
>>> DVweight[2]
34
>>> DVweight[0]  #  default edge weight is 1
1
>>> sum(span for n, span in DVweight)  # sum weighted degrees
70

>>> DVnbunch = G.degree(nbunch=(1, 2))
>>> assert len(list(DVnbunch)) == 2  # iteration over nbunch only
Nc                 0   Xl         [        US5      (       a  UR                  OUR                  U l        [        US5      (       a  UR                  OUR                  U l        Uc  U R                  O[        UR                  U5      5      U l        X0l        g )N_succ_pred)	_graphhasattrr   _adjr   rf   nbunch_iterr   _weight)r#   Gnbunchweights       r$   r1   DiDegreeView.__init__  se     '7 3 3QWW
 '7 3 3QWW
$*NdjjQ]]6=R8Sr'   c                 D   Uc.  X R                   :X  a  U $ U R                  U R                  S U5      $  XR                  ;   a3  X R                   :X  a  X   $ U R                  U R                  S U5      U   $  U R                  U R                  X5      $ ! [         a     N(f = fr.   )r   rn   r   r   r   )r#   r   r   s      r$   r_   DiDegreeView.__call__  s    >%>>$++tV<<	$\\)<'~~dkk4@HH % ~~dkk6::  		s   !B B 
BBc                   ^ U R                   mU R                  U   nU R                  U   nTc  [        U5      [        U5      -   $ [	        U4S jUR                  5        5       5      [	        U4S jUR                  5        5       5      -   $ )Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7f   Ngetr   r   r   s     r$   r   +DiDegreeView.__getitem__.<locals>.<genexpr>  s     >~66&!$$~   !c              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   r     s!      E
(6"FF61r   )r   r   r   r5   sumvalues)r#   rJ   succspredsr   s       @r$   rK   DiDegreeView.__getitem__  sy    

1

1>u:E
**>u||~>> E
(-E
 B
 
 	
r'   c              #     ^#    U R                   mTcM  U R                   H<  nU R                  U   nU R                  U   nU[	        U5      [	        U5      -   4v   M>     g U R                   Hm  nU R                  U   nU R                  U   n[        U4S jUR                  5        5       5      [        U4S jUR                  5        5       5      -   nX4v   Mo     g 7f)Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   (DiDegreeView.__iter__.<locals>.<genexpr>       En&&++nr   c              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   r     s!      L0>"FF61%%r   )r   r   r   r   r5   r   r   r#   rJ   r   r   degr   s        @r$   r;   DiDegreeView.__iter__  s     >[[

1

1#e*s5z122 !
 [[

1

1EellnEE L05L I  h !s   CCc                 ,    [        U R                  5      $ r.   r4   r"   s    r$   r6   DiDegreeView.__len__  r8   r'   c                 *    [        [        U 5      5      $ r.   rd   r"   s    r$   rg   DiDegreeView.__str__  ri   r'   c                 L    U R                   R                   S[        U 5       S3$ rk   )rn   rE   r   r"   s    r$   rp   DiDegreeView.__repr__  $    ..))*!DJ<q99r'   )r   r   r   r   r   )NN)rE   rs   rt   ru   rv   r1   r_   rK   r;   r6   rg   rp   ry   rz   r'   r$   r   r     s+    #J;
  :r'   r   c                   $    \ rS rSrSrS rS rSrg)r   i  a  A DegreeView class to act as G.degree for a NetworkX Graph

Typical usage focuses on iteration over `(node, degree)` pairs.
The degree is by default the number of edges incident to the node.
Optional argument `weight` enables weighted degree using the edge
attribute named in the `weight` argument.  Reporting and iteration
can also be restricted to a subset of nodes using `nbunch`.

Additional functionality include node lookup so that `G.degree[n]`
reported the (possibly weighted) degree of node `n`. Calling the
view creates a view with different arguments `nbunch` or `weight`.

Parameters
==========
graph : NetworkX graph-like class
nbunch : node, container of nodes, or None meaning all nodes (default=None)
weight : string or None (default=None)

Notes
-----
DegreeView can still lookup any node even if nbunch is specified.

Examples
--------
>>> G = nx.path_graph(3)
>>> DV = G.degree()
>>> assert DV[2] == 1
>>> assert G.degree[2] == 1
>>> assert sum(deg for n, deg in DV) == 4

>>> DVweight = G.degree(weight="span")
>>> G.add_edge(1, 2, span=34)
>>> DVweight[2]
34
>>> DVweight[0]  #  default edge weight is 1
1
>>> sum(span for n, span in DVweight)  # sum weighted degrees
70

>>> DVnbunch = G.degree(nbunch=(1, 2))
>>> assert len(list(DVnbunch)) == 2  # iteration over nbunch only
c                    ^ U R                   mU R                  U   nTc  [        U5      X;   -   $ [        U4S jUR	                  5        5       5      X;   =(       a    X!   R                  TS5      -   $ )Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   )DegreeView.__getitem__.<locals>.<genexpr>       =}66&!$$}r   r   )r   r   r5   r   r   r   r#   rJ   nbrsr   s      @r$   rK   DegreeView.__getitem__
  sd    zz!}>t9	**=t{{}==I0$'++fa0
 	
r'   c              #   n  ^#    U R                   mTc7  U R                   H&  nU R                  U   nU[        U5      X;   -   4v   M(     g U R                   HZ  nU R                  U   n[	        U4S jUR                  5        5       5      X;   =(       a    X!   R                  TS5      -   nX4v   M\     g 7f)Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   &DegreeView.__iter__.<locals>.<genexpr>  s     Dm&&++mr   r   )r   r   r   r5   r   r   r   r#   rJ   r   r   r   s       @r$   r;   DegreeView.__iter__  s     >[[zz!}#d)qy122 ! [[zz!}DdkkmDDI8$'++fa"8 h !s   B2B5rz   NrE   rs   rt   ru   rv   rK   r;   ry   rz   r'   r$   r   r     s    )V
r'   r   c                   $    \ rS rSrSrS rS rSrg)r   i"  zEA DegreeView class to report out_degree for a DiGraph; See DegreeViewc                    ^  T R                   nT R                  U   nT R                   c  [        U5      $ [        U 4S jUR	                  5        5       5      $ )Nc              3   Z   >#    U  H   oR                  TR                  S 5      v   M"     g7fr   )r   r   )r   r   r#   s     r$   r   ,OutDegreeView.__getitem__.<locals>.<genexpr>*  s!     C]r66$,,**]r   )r   r   r5   r   r   )r#   rJ   r   r   s   `   r$   rK   OutDegreeView.__getitem__%  sD    zz!}<<t9CT[[]CCCr'   c              #   $  ^#    U R                   mTc2  U R                   H!  nU R                  U   nU[        U5      4v   M#     g U R                   H:  nU R                  U   n[	        U4S jUR                  5        5       5      nX4v   M<     g 7f)Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   )OutDegreeView.__iter__.<locals>.<genexpr>5  r   r   )r   r   r   r5   r   r   )r#   rJ   r   r   r   s       @r$   r;   OutDegreeView.__iter__,  w     >[[

1#e*o% ! [[

1EellnEEh !   BBrz   Nr   rz   r'   r$   r   r   "  s    OD
r'   r   c                   $    \ rS rSrSrS rS rSrg)r   i9  zDA DegreeView class to report in_degree for a DiGraph; See DegreeViewc                    ^ U R                   mU R                  U   nTc  [        U5      $ [        U4S jUR	                  5        5       5      $ )Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   +InDegreeView.__getitem__.<locals>.<genexpr>A  r   r   )r   r   r5   r   r   r   s      @r$   rK   InDegreeView.__getitem__<  s?    zz!}>t9=t{{}===r'   c              #   $  ^#    U R                   mTc2  U R                   H!  nU R                  U   nU[        U5      4v   M#     g U R                   H:  nU R                  U   n[	        U4S jUR                  5        5       5      nX4v   M<     g 7f)Nc              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   s     r$   r   (InDegreeView.__iter__.<locals>.<genexpr>L  r   r   )r   r   r   r5   r   r   )r#   rJ   r   r   r   s       @r$   r;   InDegreeView.__iter__C  r   r   rz   Nr   rz   r'   r$   r   r   9  s    N>
r'   r   c                   $    \ rS rSrSrS rS rSrg)r   iP  z=A DegreeView class for undirected multigraphs; See DegreeViewc                 V  ^ U R                   mU R                  U   nTc9  [        S UR                  5        5       5      X;   =(       a    [	        X!   5      -   $ [        U4S jUR                  5        5       5      nX;   a(  U[        U4S jX!   R                  5        5       5      -  nU$ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r5   r   keyss     r$   r   .MultiDegreeView.__getitem__.<locals>.<genexpr>W       ;]Ts4yy]   c              3   t   >#    U  H-  oR                  5         H  o"R                  TS 5      v   M     M/     g7fr   r   r   r   key_dictr   r   s      r$   r   r   [  s/      
-:OODUqEE&!DU]   58c              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r   r   r   s     r$   r   r   _  s     B1AAuuVQ''1Ar   )r   r   r   r   r5   r   s       @r$   rK   MultiDegreeView.__getitem__S  s    zz!}>;T[[];;	*c$'l   
-1[[]
 
 93B1ABBBC
r'   c              #     ^#    U R                   mTca  U R                   HP  nU R                  U   n[        S UR	                  5        5       5      X;   =(       a    [        X!   5      -   nX4v   MR     g U R                   Hg  nU R                  U   n[        U4S jUR	                  5        5       5      nX;   a(  U[        U4S jX!   R	                  5        5       5      -  nX4v   Mi     g 7f)Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   +MultiDegreeView.__iter__.<locals>.<genexpr>g       >#d))r   c              3   x   >#    U  H/  nUR                  5         H  nUR                  TS 5      v   M     M1     g7fr   r   r   s      r$   r   r  n  :      $1%__. EE&!$$. %$1   7:c              3   F   >#    U  H  oR                  TS 5      v   M     g7fr   r   r  s     r$   r   r  t  s     J9IAuuVQ//9Ir   )r   r   r   r   r   r5   r   s       @r$   r;   MultiDegreeView.__iter__b  s     >[[zz!}>>>I.#dg, h ! [[zz!} $(KKM 
 93J9IJJJCh !s   C)C,rz   Nr   rz   r'   r$   r   r   P  s    Gr'   r   c                   $    \ rS rSrSrS rS rSrg)r   ix  z3A DegreeView class for MultiDiGraph; See DegreeViewc                 r  ^ U R                   mU R                  U   nU R                  U   nTcA  [        S UR	                  5        5       5      [        S UR	                  5        5       5      -   $ [        U4S jUR	                  5        5       5      [        U4S jUR	                  5        5       5      -   nU$ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   0DiMultiDegreeView.__getitem__.<locals>.<genexpr>  s     <^Ts4yy^r   c              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   r    s      C&4dD		nr   c              3   t   >#    U  H-  oR                  5         H  o"R                  TS 5      v   M     M/     g7fr   r   r   s      r$   r   r    s/      
-;__EVEE&!EV^r  c              3   t   >#    U  H-  oR                  5         H  o"R                  TS 5      v   M     M/     g7fr   r   r   s      r$   r   r    s/      
-;__EVEE&!EV^r  )r   r   r   r   r   r   s        @r$   rK   DiMultiDegreeView.__getitem__{  s    

1

1><U\\^<<s C&+llnC @    
-2\\^
 
 
-2\\^
 


 
r'   c              #     ^#    U R                   mTcx  U R                   Hg  nU R                  U   nU R                  U   n[	        S UR                  5        5       5      [	        S UR                  5        5       5      -   nX4v   Mi     g U R                   Hm  nU R                  U   nU R                  U   n[	        U4S jUR                  5        5       5      [	        U4S jUR                  5        5       5      -   nX4v   Mo     g 7f)Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   -DiMultiDegreeView.__iter__.<locals>.<genexpr>  s     ?#d))r   c              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   r    s      F*8$CII.r   c              3   x   >#    U  H/  nUR                  5         H  nUR                  TS 5      v   M     M1     g7fr   r   r   s      r$   r   r    s:      $2%__. EE&!$$. %$2r  c              3   x   >#    U  H/  nUR                  5         H  nUR                  TS 5      v   M     M1     g7fr   r   r   s      r$   r   r    s:      $2%__. EE&!$$. %$2r  )r   r   r   r   r   r   r   s        @r$   r;   DiMultiDegreeView.__iter__  s     >[[

1

1???# F*/,,.F C  h ! [[

1

1 $)LLN   $)LLN 	 h !s   DD	rz   Nr   rz   r'   r$   r   r   x  s    = r'   r   c                   $    \ rS rSrSrS rS rSrg)r   i  zDA DegreeView class for inward degree of MultiDiGraph; See DegreeViewc                    ^ U R                   mU R                  U   nTc   [        S UR                  5        5       5      $ [        U4S jUR                  5        5       5      $ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   r]   s     r$   r   0InMultiDegreeView.__getitem__.<locals>.<genexpr>  r   r   c              3   t   >#    U  H-  oR                  5         H  o"R                  TS 5      v   M     M/     g7fr   r   r   s      r$   r   r!    /      
-:OODUqEE&!DU]r  )r   r   r   r   r   s      @r$   rK   InMultiDegreeView.__getitem__  U    zz!}>;T[[];;; 
-1[[]
 
 	
r'   c              #   P  ^#    U R                   mTcH  U R                   H7  nU R                  U   n[        S UR	                  5        5       5      nX4v   M9     g U R                   H:  nU R                  U   n[        U4S jUR	                  5        5       5      nX4v   M<     g 7f)Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   -InMultiDegreeView.__iter__.<locals>.<genexpr>  r  r   c              3   x   >#    U  H/  nUR                  5         H  nUR                  TS 5      v   M     M1     g7fr   r   r   s      r$   r   r(    r
  r  )r   r   r   r   r   r   s       @r$   r;   InMultiDegreeView.__iter__       >[[zz!}>>>h !
 [[zz!} $(KKM 
 h !   B#B&rz   Nr   rz   r'   r$   r   r     s    N
r'   r   c                   $    \ rS rSrSrS rS rSrg)r   i  zEA DegreeView class for outward degree of MultiDiGraph; See DegreeViewc                    ^ U R                   mU R                  U   nTc   [        S UR                  5        5       5      $ [        U4S jUR                  5        5       5      $ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   1OutMultiDegreeView.__getitem__.<locals>.<genexpr>  r   r   c              3   t   >#    U  H-  oR                  5         H  o"R                  TS 5      v   M     M/     g7fr   r   r   s      r$   r   r0    r#  r  )r   r   r   r   r   s      @r$   rK   OutMultiDegreeView.__getitem__  r%  r'   c              #   P  ^#    U R                   mTcH  U R                   H7  nU R                  U   n[        S UR	                  5        5       5      nX4v   M9     g U R                   H:  nU R                  U   n[        U4S jUR	                  5        5       5      nX4v   M<     g 7f)Nc              3   8   #    U  H  n[        U5      v   M     g 7fr.   r   r   s     r$   r   .OutMultiDegreeView.__iter__.<locals>.<genexpr>  r  r   c              3   x   >#    U  H/  nUR                  5         H  nUR                  TS 5      v   M     M1     g7fr   r   r   s      r$   r   r5    r
  r  )r   r   r   r   r   r   s       @r$   r;   OutMultiDegreeView.__iter__  r+  r,  rz   Nr   rz   r'   r$   r   r     s    O
r'   r   c                       \ rS rSrSrg)EdgeViewABCi  rz   N)rE   rs   rt   ru   ry   rz   r'   r$   r9  r9    s    r'   r9  c                   X    \ rS rSrSrSrS rS rSSS.S jjrS	 r	S
 r
S rS rS rSrg)r   i  z;EdgeDataView for outward edges of DiGraph; See EdgeDataView)_viewer_nbunchr}   r~   _adjdict_nodes_nbrs_reportc                 `    U R                   U R                  U R                  U R                  S.$ )N)viewerr   r]   r^   )r;  r<  r}   r~   r"   s    r$   r%   OutEdgeDataView.__getstate__  s(    llllJJ}}	
 	
r'   c                 (    U R                   " S0 UD6  g Nrz   r1   r)   s     r$   r+   OutEdgeDataView.__setstate__       r'   Nr^   c                V  ^^^^ Xl         UR                  =mU l        Tc  TR                  U l        O:[        R                  UR                  R                  T5      5      mUU4S jU l        TU l        TU l	        TU l
        TSL a	  S U l        g TSL a	  S U l        g UU4S jU l        g )Nc                  <   > T V s/ s H	  o TU    4PM     sn $ s  sn f r.   rz   rJ   adjdictr   s    r$   <lambda>*OutEdgeDataView.__init__.<locals>.<lambda>      'HAGAJ'H'H   Tc                 
    XU4$ r.   rz   rJ   nbrr   s      r$   rM  rN    s    qrlr'   Fc                     X4$ r.   rz   rR  s      r$   rM  rN    s    qhr'   c                 &   > TU;   a  XUT   4$ XT4$ r.   rz   )rJ   rS  r   r]   r^   s      r$   rM  rN    s*    2: %&BtH#5 $'g&$'r'   )r;  r=  r   r>  r   fromkeysr   r   r<  r}   r~   r?  )r#   rA  r   r]   r^   rL  s     ```@r$   r1   OutEdgeDataView.__init__  s    "(//1$->&}}D ]]6==#<#<V#DEFHD
4<:DLU]6DL' Lr'   c                 B    [        S U R                  5        5       5      $ )Nc              3   <   #    U  H  u  p[        U5      v   M     g 7fr.   r   r   rJ   r   s      r$   r   *OutEdgeDataView.__len__.<locals>.<genexpr>       ?,>3t99,>   r   r>  r"   s    r$   r6   OutEdgeDataView.__len__      ?D,<,<,>???r'   c                 8   ^  U 4S jT R                  5        5       $ )Nc              3      >#    U  H3  u  pUR                  5         H  u  p4TR                  XU5      v   M     M5     g 7fr.   r   r?  r   rJ   r   rS  r   r#   s        r$   r   +OutEdgeDataView.__iter__.<locals>.<genexpr>  s=      
-::< LL$$' %-   ;>r>  r"   s   `r$   r;   OutEdgeDataView.__iter__      
++-
 	
r'   c                     US S u  p#U R                   b  X R                   ;  a  g U R                  U   U   nXR                  X#U5      :H  $ ! [         a     gf = fN   Fr<  r=  KeyErrorr?  r#   euvr   s        r$   rN   OutEdgeDataView.__contains__%  g    !u<<#(=	MM!$Q'E LLu---  		   A 
AAc                 *    [        [        U 5      5      $ r.   rd   r"   s    r$   rg   OutEdgeDataView.__str__/  ri   r'   c                 L    U R                   R                   S[        U 5       S3$ rk   rn   rE   rf   r"   s    r$   rp   OutEdgeDataView.__repr__2  r   r'   )r=  r}   r~   r<  r>  r?  r;  rZ   )rE   rs   rt   ru   rv   rw   r%   r+   r1   r6   r;   rN   rg   rp   ry   rz   r'   r$   r   r     s<    EI
4 0@
.:r'   r   c                   .    \ rS rSrSrSrS rS rS rSr	g)r   i6  a  A EdgeDataView class for edges of Graph

This view is primarily used to iterate over the edges reporting
edges as node-tuples with edge data optionally reported. The
argument `nbunch` allows restriction to edges incident to nodes
in that container/singleton. The default (nbunch=None)
reports all edges. The arguments `data` and `default` control
what edge data is reported. The default `data is False` reports
only node-tuples for each edge. If `data is True` the entire edge
data dict is returned. Otherwise `data` is assumed to hold the name
of the edge attribute to report with default `default` if  that
edge attribute is not present.

Parameters
----------
nbunch : container of nodes, node or None (default None)
data : False, True or string (default False)
default : default value (default None)

Examples
--------
>>> G = nx.path_graph(3)
>>> G.add_edge(1, 2, foo="bar")
>>> list(G.edges(data="foo", default="biz"))
[(0, 1, 'biz'), (1, 2, 'bar')]
>>> assert (0, 1, "biz") in G.edges(data="foo", default="biz")
rz   c                 &    [        S U  5       5      $ )Nc              3   &   #    U  H  nS v   M	     g7fr   rz   r   rp  s     r$   r   'EdgeDataView.__len__.<locals>.<genexpr>V       #d1d   r   r"   s    r$   r6   EdgeDataView.__len__U      #d###r'   c              #      #    0 nU R                  5        H=  u  p#UR                  5        H   u  pEXA;  d  M  U R                  X$U5      v   M"     SX'   M?     Ag 7fNr   r>  r   r?  )r#   seenrJ   r   rS  r   s         r$   r;   EdgeDataView.__iter__X  sU     '')GA::<?,,qr22 ( DG	 *
 s
   0A"Ac                     US S u  p#U R                   b  X R                   ;  a  X0R                   ;  a  g U R                  U   U   nXR                  X#U5      :H  $ ! [         a     gf = frk  rm  ro  s        r$   rN   EdgeDataView.__contains__a  sp    !u<<#(=!<<BW	MM!$Q'E LLu---  		s   A 
A('A(N)
rE   rs   rt   ru   rv   rw   r6   r;   rN   ry   rz   r'   r$   r   r   6  s    8 I$.r'   r   c                   (    \ rS rSrSrSrS rS rSrg)r   il  zDAn EdgeDataView class for outward edges of DiGraph; See EdgeDataViewrz   c                 8   ^  U 4S jT R                  5        5       $ )Nc              3      >#    U  H3  u  pUR                  5         H  u  p4TR                  X1U5      v   M     M5     g 7fr.   rc  rd  s        r$   r   *InEdgeDataView.__iter__.<locals>.<genexpr>r  s=      
-::< LL$$' %-rf  rg  r"   s   `r$   r;   InEdgeDataView.__iter__q  ri  r'   c                     US S u  p#U R                   b  X0R                   ;  a  g U R                  U   U   nXR                  X#U5      :H  $ ! [         a     gf = frk  rm  ro  s        r$   rN   InEdgeDataView.__contains__x  rt  ru  N	rE   rs   rt   ru   rv   rw   r;   rN   ry   rz   r'   r$   r   r   l  s    NI
.r'   r   c                   N    \ rS rSrSrSrS rS rSSSS.S	 jjrS
 r	S r
S rSrg)r   i  zCAn EdgeDataView for outward edges of MultiDiGraph; See EdgeDataView)r   c                 v    U R                   U R                  U R                  U R                  U R                  S.$ )N)rA  r   r   r]   r^   )r;  r<  r   r}   r~   r"   s    r$   r%   !OutMultiEdgeDataView.__getstate__  s/    llllIIJJ}}
 	
r'   c                 (    U R                   " S0 UD6  g rD  rE  r)   s     r$   r+   !OutMultiEdgeDataView.__setstate__  rG  r'   NFr^   r   c                  ^^^^ Xl         UR                  =mU l        XPl        Tc  TR                  U l        O:[
        R                  UR                  R                  T5      5      mUU4S jU l        TU l	        TU l
        TU l        TSL a  USL a	  S U l        g S U l        g TSL a  USL a	  S U l        g S U l        g USL a  UU4S jU l        g UU4S	 jU l        g )
Nc                  <   > T V s/ s H	  o TU    4PM     sn $ s  sn f r.   rz   rK  s    r$   rM  /OutMultiEdgeDataView.__init__.<locals>.<lambda>  rO  rP  Tc                 
    XX#4$ r.   rz   rJ   rS  kr   s       r$   rM  r    s    aa_r'   c                 
    XU4$ r.   rz   r  s       r$   rM  r    s    ab\r'   Fc                 
    XU4$ r.   rz   r  s       r$   rM  r    s    aa[r'   c                     X4$ r.   rz   r  s       r$   rM  r    s    aXr'   c                 (   > TU;   a  XX#T   4$ XUT4$ r.   rz   rJ   rS  r  r   r]   r^   s       r$   rM  r    s,    rz ,-1h*? +.!W-+.r'   c                 &   > TU;   a  XUT   4$ XT4$ r.   rz   r  s       r$   rM  r    s*    rz ,-2d8*< ++'*++r'   )r;  r=  r   r   r>  r   rV  r   r   r<  r}   r~   r?  )r#   rA  r   r]   r^   r   rL  s     ``` @r$   r1   OutMultiEdgeDataView.__init__  s    "(//1$-	>&}}D ]]6==#<#<V#DEFHD
4<t|DAU]t|@=t|. + r'   c                 &    [        S U  5       5      $ )Nc              3   &   #    U  H  nS v   M	     g7fr   rz   r~  s     r$   r   /OutMultiEdgeDataView.__len__.<locals>.<genexpr>  r  r  r  r"   s    r$   r6   OutMultiEdgeDataView.__len__  r  r'   c                 8   ^  U 4S jT R                  5        5       $ )Nc           	   3      >#    U  HM  u  pUR                  5         H3  u  p4UR                  5         H  u  pVTR                  XXV5      v   M     M5     MO     g 7fr.   rc  r   rJ   r   rS  kdr  r   r#   s          r$   r   0OutMultiEdgeDataView.__iter__.<locals>.<genexpr>  sT      
-::< LL'' $ (' (-   AArg  r"   s   `r$   r;   OutMultiEdgeDataView.__iter__      
++-
 	
r'   c                 f  ^ ^^^ TS S u  mmT R                   b  TT R                   ;  a  g T R                  T   T   nT R                  SL a   TS   n X#   nTT R	                  TTX45      :H  $ [        UU UU4S jUR                  5        5       5      $ ! [         a     gf = f! [         a     gf = f)Nrl  FTc              3   T   >#    U  H  u  pTTR                  TTX5      :H  v   M     g 7fr.   r?  r   r  r   rp  r#   rq  rr  s      r$   r   4OutMultiEdgeDataView.__contains__.<locals>.<genexpr>  %     M}ea1Q111}   %(r<  r=  rn  r   r?  anyr   r#   rp  kdictr  r   rq  rr  s   ``   @@r$   rN   !OutMultiEdgeDataView.__contains__  s    !u1<<#(=	MM!$Q'E 99!AX Q1111Mu{{}MMM  		  s#   B B# 
B B #
B0/B0)r=  r}   r~   r<  r>  r?  r;  r   rZ   )rE   rs   rt   ru   rv   rw   r%   r+   r1   r6   r;   rN   ry   rz   r'   r$   r   r     s3    MI
$4e $L$
Nr'   r   c                   (    \ rS rSrSrSrS rS rSrg)r   i  z?An EdgeDataView class for edges of MultiGraph; See EdgeDataViewrz   c           	   #      #    0 nU R                  5        HV  u  p#UR                  5        H9  u  pEXA;  d  M  UR                  5        H  u  pgU R                  X$Xg5      v   M     M;     SX'   MX     Ag 7fr  r  r#   r  rJ   r   rS  r  r  r   s           r$   r;   MultiEdgeDataView.__iter__  sg     '')GA::<?!#"ll1199 ", ( DG * s
   0A1;A1c                   ^ ^^^ TS S u  mmT R                   b!  TT R                   ;  a  TT R                   ;  a  g T R                  T   T   nT R                  SL a   TS   n X#   nTT R	                  TTX45      :H  $ [        UU UU4S jUR                  5        5       5      $ ! [         a'     T R                  T   T   n Nt! [         a      gf = ff = f! [         a     gf = f)Nrl  FTc              3   T   >#    U  H  u  pTTR                  TTX5      :H  v   M     g 7fr.   r  r  s      r$   r   1MultiEdgeDataView.__contains__.<locals>.<genexpr>  r  r  r  r  s   ``   @@r$   rN   MultiEdgeDataView.__contains__  s    !u1<<#(=!4<<BW	MM!$Q'E 99!AX Q1111Mu{{}MMM  	a(+ 	  s;   B# #C #
C.C
CCCC
C$#C$Nr  rz   r'   r$   r   r     s    IINr'   r   c                   (    \ rS rSrSrSrS rS rSrg)r   i  zBAn EdgeDataView for inward edges of MultiDiGraph; See EdgeDataViewrz   c                 8   ^  U 4S jT R                  5        5       $ )Nc           	   3      >#    U  HM  u  pUR                  5         H3  u  p4UR                  5         H  u  pVTR                  X1XV5      v   M     M5     MO     g 7fr.   rc  r  s          r$   r   /InMultiEdgeDataView.__iter__.<locals>.<genexpr>  sT      
-::< LL'' $ (' (-r  rg  r"   s   `r$   r;   InMultiEdgeDataView.__iter__   r  r'   c                 D  ^ ^^^ TS S u  mmT R                   b  TT R                   ;  a  g T R                  T   T   nT R                  SL a  TS   nX#   nTT R	                  TTX45      :H  $ [        UU UU4S jUR                  5        5       5      $ ! [         a     gf = f)Nrl  FTc              3   T   >#    U  H  u  pTTR                  TTX5      :H  v   M     g 7fr.   r  r  s      r$   r   3InMultiEdgeDataView.__contains__.<locals>.<genexpr>  r  r  r  r  s   ``   @@r$   rN    InMultiEdgeDataView.__contains__  s    !u1<<#(=	MM!$Q'E 99!ABQ1111Mu{{}MMM  		s   B 
BBNr  rz   r'   r$   r   r     s    LI
Nr'   r   c                       \ rS rSrSrSrS rS r\S 5       r	\
rS rS rS	 rS
 rS rSSS.S jjrSS jrS rS rSrg)r	   i  z/A EdgeView class for outward edges of a DiGraphr=  r   r>  c                 4    U R                   U R                  S.$ )Nr   r=  r  r"   s    r$   r%   OutEdgeView.__getstate__  s    ++4==AAr'   c                 b    US   U l         US   U l        U R                  R                  U l        g Nr   r=  r   r=  r   r>  r)   s     r$   r+   OutEdgeView.__setstate__   +    Hoj)==..r'   c                     [        U5      $ r.   rQ   rS   s     r$   rV   OutEdgeView._from_iterable%  rX   r'   c                     Xl         [        US5      (       a  UR                  OUR                  U l        U R                  R
                  U l        g )Nsucc)r   r   r   r   r=  r   r>  r#   r   s     r$   r1   OutEdgeView.__init__+  6    #*1f#5#5166==..r'   c                 B    [        S U R                  5        5       5      $ )Nc              3   <   #    U  H  u  p[        U5      v   M     g 7fr.   r   rZ  s      r$   r   &OutEdgeView.__len__.<locals>.<genexpr>2  r\  r]  r^  r"   s    r$   r6   OutEdgeView.__len__1  r`  r'   c              #   Z   #    U R                  5        H  u  pU H  nX4v   M
     M     g 7fr.   rg  r#   rJ   r   rS  s       r$   r;   OutEdgeView.__iter__4  s+     '')GAh  *   )+c                 N     Uu  p#X0R                   U   ;   $ ! [         a     gf = frZ   r=  rn  r#   rp  rq  rr  s       r$   rN   OutEdgeView.__contains__9  2    	DAa((( 		    
$$c           
      B   [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eUu  p# U R                  U   U   $ ! [         a  n[        SU S35      eS nAff = f)N- does not support slicing, try list(G.edges)[r>   r?   z	The edge z is not in the graph.)r@   rA   rB   rC   rD   rE   rF   rG   rH   r=  rn  )r#   rp  rq  rr  exs        r$   rK   OutEdgeView.__getitem__A  s    a"":&&' (%%&WWIQqvvhaxqB  	A==#A&& 	AYqc)>?@@	As   .B   
B
BBNrH  c                6    Uc  USL a  U $ U R                  XX#S9$ )NFrH  dataview)r#   r   r]   r^   s       r$   r_   OutEdgeView.__call__N  s%    >demK}}T4}AAr'   c                 6    Uc  USL a  U $ U R                  XXS9$ )a  
Return a read-only view of edge data.

Parameters
----------
data : bool or edge attribute key
    If ``data=True``, then the data view maps each edge to a dictionary
    containing all of its attributes. If `data` is a key in the edge
    dictionary, then the data view maps each edge to its value for
    the keyed attribute. In this case, if the edge doesn't have the
    attribute, the `default` value is returned.
default : object, default=None
    The value used when an edge does not have a specific attribute
nbunch : container of nodes, optional (default=None)
    Allows restriction to edges only involving certain nodes. All edges
    are considered by default.

Returns
-------
dataview
    Returns an `EdgeDataView` for undirected Graphs, `OutEdgeDataView`
    for DiGraphs, `MultiEdgeDataView` for MultiGraphs and
    `OutMultiEdgeDataView` for MultiDiGraphs.

Notes
-----
If ``data=False``, returns an `EdgeView` without any edge data.

See Also
--------
EdgeDataView
OutEdgeDataView
MultiEdgeDataView
OutMultiEdgeDataView

Examples
--------
>>> G = nx.Graph()
>>> G.add_edges_from(
...     [
...         (0, 1, {"dist": 3, "capacity": 20}),
...         (1, 2, {"dist": 4}),
...         (2, 0, {"dist": 5}),
...     ]
... )

Accessing edge data with ``data=True`` (the default) returns an
edge data view object listing each edge with all of its attributes:

>>> G.edges.data()
EdgeDataView([(0, 1, {'dist': 3, 'capacity': 20}), (0, 2, {'dist': 5}), (1, 2, {'dist': 4})])

If `data` represents a key in the edge attribute dict, a dataview listing
each edge with its value for that specific key is returned:

>>> G.edges.data("dist")
EdgeDataView([(0, 1, 3), (0, 2, 5), (1, 2, 4)])

`nbunch` can be used to limit the edges:

>>> G.edges.data("dist", nbunch=[0])
EdgeDataView([(0, 1, 3), (0, 2, 5)])

If a specific key is not found in an edge attribute dict, the value
specified by `default` is used:

>>> G.edges.data("capacity")
EdgeDataView([(0, 1, 20), (0, 2, None), (1, 2, None)])

Note that there is no check that the `data` key is present in any of
the edge attribute dictionaries:

>>> G.edges.data("speed")
EdgeDataView([(0, 1, None), (0, 2, None), (1, 2, None)])
FrH  r  )r#   r]   r^   r   s       r$   r]   OutEdgeView.dataS  s(    X >demK}}T4}AAr'   c                 *    [        [        U 5      5      $ r.   rd   r"   s    r$   rg   OutEdgeView.__str__  ri   r'   c                 L    U R                   R                   S[        U 5       S3$ rk   ry  r"   s    r$   rp   OutEdgeView.__repr__  r   r'   rZ   )TNN)rE   rs   rt   ru   rv   rw   r%   r+   rx   rV   r   r  r1   r6   r;   rN   rK   r_   r]   rg   rp   ry   rz   r'   r$   r	   r	     sk    95IB/
   H/@

AB4 B
NBb:r'   r	   c                   2    \ rS rSrSrSr\rS rS r	S r
Srg)r   i  a  A EdgeView class for edges of a Graph

This densely packed View allows iteration over edges, data lookup
like a dict and set operations on edges represented by node-tuples.
In addition, edge data can be controlled by calling this object
possibly creating an EdgeDataView. Typically edges are iterated over
and reported as `(u, v)` node tuples or `(u, v, key)` node/key tuples
for multigraphs. Those edge representations can also be using to
lookup the data dict for any edge. Set operations also are available
where those tuples are the elements of the set.
Calling this object with optional arguments `data`, `default` and `keys`
controls the form of the tuple (see EdgeDataView). Optional argument
`nbunch` allows restriction to edges only involving certain nodes.

If `data is False` (the default) then iterate over 2-tuples `(u, v)`.
If `data is True` iterate over 3-tuples `(u, v, datadict)`.
Otherwise iterate over `(u, v, datadict.get(data, default))`.
For Multigraphs, if `keys is True`, replace `u, v` with `u, v, key` above.

Parameters
==========
graph : NetworkX graph-like class
nbunch : (default= all nodes in graph) only report edges with these nodes
keys : (only for MultiGraph. default=False) report edge key in tuple
data : bool or string (default=False) see above
default : object (default=None)

Examples
========
>>> G = nx.path_graph(4)
>>> EV = G.edges()
>>> (2, 3) in EV
True
>>> for u, v in EV:
...     print((u, v))
(0, 1)
(1, 2)
(2, 3)
>>> assert EV & {(1, 2), (3, 4)} == {(1, 2)}

>>> EVdata = G.edges(data="color", default="aqua")
>>> G.add_edge(2, 3, color="blue")
>>> assert (2, 3, "blue") in EVdata
>>> for u, v, c in EVdata:
...     print(f"({u}, {v}) has color: {c}")
(0, 1) has color: aqua
(1, 2) has color: aqua
(2, 3) has color: blue

>>> EVnbunch = G.edges(nbunch=2)
>>> assert (2, 3) in EVnbunch
>>> assert (0, 1) not in EVnbunch
>>> for u, v in EVnbunch:
...     assert u == 2 or v == 2

>>> MG = nx.path_graph(4, create_using=nx.MultiGraph)
>>> EVmulti = MG.edges(keys=True)
>>> (2, 3, 0) in EVmulti
True
>>> (2, 3) in EVmulti  # 2-tuples work even when keys is True
True
>>> key = MG.add_edge(2, 3)
>>> for u, v, k in EVmulti:
...     print((u, v, k))
(0, 1, 0)
(1, 2, 0)
(2, 3, 0)
(2, 3, 1)
rz   c                 L    S U R                  5        5       n[        U5      S-  $ )Nc              3   F   #    U  H  u  p[        U5      X;   -   v   M     g 7fr.   r   rZ  s      r$   r   #EdgeView.__len__.<locals>.<genexpr>  s     N;MCI+;Ms   !rl  )r>  r   )r#   num_nbrss     r$   r6   EdgeView.__len__  s$    N4;K;K;MN8}!!r'   c              #      #    0 nU R                  5        H'  u  p#[        U5       H  nXA;  d  M
  X$4v   M     SX'   M)     Ag 7fr  )r>  rf   )r#   r  rJ   r   rS  s        r$   r;   EdgeView.__iter__  sG     '')GADz?(N " DG	 *
 s
   )AAc                      US S u  p#X0R                   U   ;   =(       d    X R                   U   ;   $ ! [        [        4 a     gf = frk  )r=  rn  r   r  s       r$   rN   EdgeView.__contains__  sN    	Ra5DAa((AAq1A,AA*% 		s   /2 AAN)rE   rs   rt   ru   rv   rw   r   r  r6   r;   rN   ry   rz   r'   r$   r   r     s$    DL IH"r'   r   c                   >    \ rS rSrSrSrS r\rS r	S r
S rS rS	rg
)r
   i  z.A EdgeView class for inward edges of a DiGraphrz   c                 b    US   U l         US   U l        U R                  R                  U l        g r  r  r)   s     r$   r+   InEdgeView.__setstate__  r  r'   c                     Xl         [        US5      (       a  UR                  OUR                  U l        U R                  R
                  U l        g Npredr   r   r   r   r=  r   r>  r  s     r$   r1   InEdgeView.__init__  r  r'   c              #   Z   #    U R                  5        H  u  pU H  nX14v   M
     M     g 7fr.   rg  r  s       r$   r;   InEdgeView.__iter__  s+     '')GAh  *r  c                 N     Uu  p#X R                   U   ;   $ ! [         a     gf = frZ   r  r  s       r$   rN   InEdgeView.__contains__!  r  r  c           
          [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eUu  p#U R                  U   U   $ Nz0 does not support slicing, try list(G.in_edges)[r>   r?   
r@   rA   rB   rC   rD   rE   rF   rG   rH   r=  r  s       r$   rK   InEdgeView.__getitem__(  sy    a"":&&' ((()y!&&166(!E  }}Q""r'   r  N)rE   rs   rt   ru   rv   rw   r+   r   r  r1   r;   rN   rK   ry   rz   r'   r$   r
   r
     s*    8I/
 H/

#r'   r
   c                   V    \ rS rSrSrSr\rS rS r	S r
S rSSS	S
.S jjrSS jrSrg)r   i2  z4A EdgeView class for outward edges of a MultiDiGraphrz   c                 B    [        S U R                  5        5       5      $ )Nc              3   p   #    U  H,  u  pUR                  5         H  u  p4[        U5      v   M     M.     g 7fr.   )r   r5   )r   rJ   r   rS  r  s        r$   r   +OutMultiEdgeView.__len__.<locals>.<genexpr>:  s,      
&8714::<ZSCJJ<J&8s   46r^  r"   s    r$   r6   OutMultiEdgeView.__len__9  s%     
&*&6&6&8
 
 	
r'   c              #      #    U R                  5        H-  u  pUR                  5        H  u  p4U H	  nXU4v   M     M     M/     g 7fr.   r>  r   r#   rJ   r   rS  r  keys         r$   r;   OutMultiEdgeView.__iter__>  s@     '')GA"jjl
 C3-' ! + *   AAc                     [        U5      nUS:X  a  Uu  p4nOUS:X  a  Uu  p4SnO[        S5      e XPR                  U   U   ;   $ ! [         a     gf = fN   rl  r   z!MultiEdge must have length 2 or 3Fr5   r   r=  rn  r#   rp  Nrq  rr  r  s         r$   rN   OutMultiEdgeView.__contains__D  h    F6GA!!VDAA@AA	a(+++ 		   A 
AAc           
         [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eUu  p#nU R                  U   U   U   $ )Nr  r>   r?   r  r#   rp  rq  rr  r  s        r$   rK   OutMultiEdgeView.__getitem__R  s    a"":&&' (%%&WWIQqvvhaxqB  a}}Q"1%%r'   NFr  c                B    Uc  USL a  USL a  U $ U R                  XX#US9$ NFTr  r  )r#   r   r]   r^   r   s        r$   r_   OutMultiEdgeView.__call__[  -    >demK}}T4t}LLr'   c                 B    Uc  USL a  USL a  U $ U R                  XXUS9$ r/  r  )r#   r]   r^   r   r   s        r$   r]   OutMultiEdgeView.data`  r1  r'   rZ   )TNNF)rE   rs   rt   ru   rv   rw   r   r  r6   r;   rN   rK   r_   r]   ry   rz   r'   r$   r   r   2  s9    >I#H

(&M4e M
Mr'   r   c                   ,    \ rS rSrSrSr\rS rS r	Sr
g)r   if  z*A EdgeView class for edges of a MultiGraphrz   c                 &    [        S U  5       5      $ )Nc              3   &   #    U  H  nS v   M	     g7fr   rz   r~  s     r$   r   (MultiEdgeView.__len__.<locals>.<genexpr>n  r  r  r  r"   s    r$   r6   MultiEdgeView.__len__m  r  r'   c              #      #    0 nU R                  5        HH  u  p#UR                  5        H+  u  pEXA;  d  M  UR                  5        H  u  pgX$U4v   M     M-     SX'   MJ     Ag 7fr  r  r  s           r$   r;   MultiEdgeView.__iter__p  s`     '')GA::<?!# qk) ", ( DG * s
   0A#-A#N)rE   rs   rt   ru   rv   rw   r   r  r6   r;   ry   rz   r'   r$   r   r   f  s    4I H$r'   r   c                   >    \ rS rSrSrSrS r\rS r	S r
S rS rS	rg
)r   i{  z3A EdgeView class for inward edges of a MultiDiGraphrz   c                 b    US   U l         US   U l        U R                  R                  U l        g r  r  r)   s     r$   r+   InMultiEdgeView.__setstate__  r  r'   c                     Xl         [        US5      (       a  UR                  OUR                  U l        U R                  R
                  U l        g r  r  r  s     r$   r1   InMultiEdgeView.__init__  r  r'   c              #      #    U R                  5        H-  u  pUR                  5        H  u  p4U H	  nX1U4v   M     M     M/     g 7fr.   r  r  s         r$   r;   InMultiEdgeView.__iter__  s@     '')GA"jjl
 C3-' ! + *r!  c                     [        U5      nUS:X  a  Uu  p4nOUS:X  a  Uu  p4SnO[        S5      e XPR                  U   U   ;   $ ! [         a     gf = fr#  r%  r&  s         r$   rN   InMultiEdgeView.__contains__  r)  r*  c           
         [        U[        5      (       aS  [        R                  " [	        U 5      R
                   SUR                   SUR                   SUR                   S35      eUu  p#nU R                  U   U   U   $ r  r  r,  s        r$   rK   InMultiEdgeView.__getitem__  s    a"":&&' ((()y!&&166(!E  a}}Q"1%%r'   r  N)rE   rs   rt   ru   rv   rw   r+   r   r  r1   r;   rN   rK   ry   rz   r'   r$   r   r   {  s*    =I/
 #H/
(&r'   r   ) rv   abcr   collections.abcr   r   networkxrB   __all__r   r   r   r   r   r   r   r   r   r   r9  r   r   r   r   r   r   r	   r   r
   r   r   r   rz   r'   r$   <module>rJ     sa  Sj  ( 6f;w f;R\<3 \<@\: \:~A AHL .< .%l %P* *Z > D	# 	
H:k H:V3.? 3.l._ ..QN? QNh!N, !NHN. N:P:#w P:f]{ ]@$# $#N1M{ 1Mh$ *,&& ,&r'   