o
    ˷e                     @   s*   d Z ddlZddgZdd ZdddZdS )	zUnary operations on graphs    N
complementreversec                    s2      }|  | fdd  D  |S )aq  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   s6    | ]\}} D ]}||vr||kr||fV  qqd S )N ).0nnbrsn2Gr   Z/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/algorithms/operators/unary.py	<genexpr>%   s   4 zcomplement.<locals>.<genexpr>)	__class__add_nodes_fromadd_edges_from	adjacency)r
   Rr   r	   r   r      s   
Tc                 C   s   |   s	td| j|dS )aa  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   r   r   r   r   *   s   
)T)__doc__networkxr   __all__r   r   r   r   r   r   <module>   s
    #