
    h                     t    S r SSKrSS/r\R                  " SS9S 5       r\R                  " SS9S	S j5       rg)
zUnary operations on graphs    N
complementreverseT)returns_graphc                    ^  T R                  5       nUR                  T 5        UR                  U 4S jT R                  5        5       5        U$ )a&  Returns the graph complement of G.

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

Returns
-------
GC : A new graph.

Notes
-----
Note that `complement` does not create self-loops and also
does not produce parallel edges for MultiGraphs.

Graph, node, and edge data are not propagated to the new graph.

Examples
--------
>>> G = nx.Graph([(1, 2), (1, 3), (2, 3), (3, 4), (3, 5)])
>>> G_complement = nx.complement(G)
>>> G_complement.edges()  # This shows the edges of the complemented graph
EdgeView([(1, 4), (1, 5), (2, 4), (2, 5), (4, 5)])

c              3   ^   >#    U  H"  u  pT  H  o3U;  d  M
  X:w  d  M  X4v   M     M$     g 7f)N ).0nnbrsn2Gs       U/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/operators/unary.py	<genexpr>complement.<locals>.<genexpr>'   s)     WWQ"t^qw!s   ---)	__class__add_nodes_fromadd_edges_from	adjacency)r   Rs   ` r   r   r      sA    8 	
AQWW H    c                 v    U R                  5       (       d  [        R                  " S5      eU R                  US9$ )a	  Returns the reverse directed graph of G.

Parameters
----------
G : directed graph
    A NetworkX directed graph
copy : bool
    If True, then a new graph is returned. If False, then the graph is
    reversed in place.

Returns
-------
H : directed graph
    The reversed G.

Raises
------
NetworkXError
    If graph is undirected.

Examples
--------
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 3), (3, 4), (3, 5)])
>>> G_reversed = nx.reverse(G)
>>> G_reversed.edges()
OutEdgeView([(2, 1), (3, 1), (3, 2), (4, 3), (5, 3)])

z#Cannot reverse an undirected graph.)copy)is_directednxNetworkXErrorr   )r   r   s     r   r   r   ,   s2    < ==??DEEyydy##r   )T)__doc__networkxr   __all___dispatchabler   r   r   r   r   <module>r       sT      
# %  & F % $ & $r   