3
Md                 @   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    j  }|j  |j fdd j D  |S )aj  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.
    c             3   s4   | ],\}} D ]}||kr||kr||fV  qqd S )N ).0nZnbrsZn2)Gr   U/var/www/html/virt/lib/python3.6/site-packages/networkx/algorithms/operators/unary.py	<genexpr>   s    zcomplement.<locals>.<genexpr>)	__class__Zadd_nodes_fromZadd_edges_fromZ	adjacency)r   Rr   )r   r   r      s
    
Tc             C   s$   | j  stjdn| j|dS dS )aD  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.

    z#Cannot reverse an undirected graph.)copyN)Zis_directednxZNetworkXErrorr   )r   r   r   r   r   r   "   s    )T)__doc__Znetworkxr   __all__r   r   r   r   r   r   <module>   s   