3
Médq  ã               @   sJ   d Z ddlmZ ddlZddddgZddd„Zd	d„ Zd
d„ Zdd„ Z	dS )zOperations on many graphs.
é    )Úzip_longestNÚ	union_allÚcompose_allÚdisjoint_union_allÚintersection_allc             C   sN   | st dƒ‚t| |ƒ}t|ƒ\}}x&|D ]\}}tj||||fƒ}d}q(W |S )aã  Returns the union of all graphs.

    The graphs must be disjoint, otherwise an exception is raised.

    Parameters
    ----------
    graphs : list of graphs
       List of NetworkX graphs

    rename : bool , default=(None, None)
       Node names of G and H can be changed by specifying the tuple
       rename=('G-','H-') (for example).  Node "u" in G is then renamed
       "G-u" and "v" in H is renamed "H-v".

    Returns
    -------
    U : a graph with the same type as the first graph in list

    Raises
    ------
    ValueError
       If `graphs` is an empty list.

    Notes
    -----
    To force a disjoint union with node relabeling, use
    disjoint_union_all(G,H) or convert_node_labels_to integers().

    Graph, edge, and node attributes are propagated to the union graph.
    If a graph attribute is present in multiple graphs, then the value
    from the last graph in the list with that attribute is used.

    See Also
    --------
    union
    disjoint_union_all
    z'cannot apply union_all to an empty listN)Ú
ValueErrorr   ÚnextÚnxÚunion)ÚgraphsÚrenameZgraphs_namesÚUÚgnameÚHÚhname© r   úS/var/www/html/virt/lib/python3.6/site-packages/networkx/algorithms/operators/all.pyr   	   s    &
c             C   s:   | st dƒ‚t| ƒ} t| ƒ}x| D ]}tj||ƒ}q"W |S )aß  Returns the disjoint union of all graphs.

    This operation forces distinct integer node labels starting with 0
    for the first graph in the list and numbering consecutively.

    Parameters
    ----------
    graphs : list
       List of NetworkX graphs

    Returns
    -------
    U : A graph with the same type as the first graph in list

    Raises
    ------
    ValueError
       If `graphs` is an empty list.

    Notes
    -----
    It is recommended that the graphs be either all directed or all undirected.

    Graph, edge, and node attributes are propagated to the union graph.
    If a graph attribute is present in multiple graphs, then the value
    from the last graph in the list with that attribute is used.
    z0cannot apply disjoint_union_all to an empty list)r   Úiterr   r	   Zdisjoint_union)r   r   r   r   r   r   r   9   s    
c             C   s:   | st dƒ‚t| ƒ} t| ƒ}x| D ]}tj||ƒ}q"W |S )aä  Returns the composition of all graphs.

    Composition is the simple union of the node sets and edge sets.
    The node sets of the supplied graphs need not be disjoint.

    Parameters
    ----------
    graphs : list
       List of NetworkX graphs

    Returns
    -------
    C : A graph with the same type as the first graph in list

    Raises
    ------
    ValueError
       If `graphs` is an empty list.

    Notes
    -----
    It is recommended that the supplied graphs be either all directed or all
    undirected.

    Graph, edge, and node attributes are propagated to the union graph.
    If a graph attribute is present in multiple graphs, then the value
    from the last graph in the list with that attribute is used.
    z)cannot apply compose_all to an empty list)r   r   r   r	   Zcompose)r   ÚCr   r   r   r   r   ^   s    
c             C   s:   | st dƒ‚t| ƒ} t| ƒ}x| D ]}tj||ƒ}q"W |S )aé  Returns a new graph that contains only the edges that exist in
    all graphs.

    All supplied graphs must have the same node set.

    Parameters
    ----------
    graphs : list
       List of NetworkX graphs

    Returns
    -------
    R : A new graph with the same type as the first graph in list

    Raises
    ------
    ValueError
       If `graphs` is an empty list.

    Notes
    -----
    Attributes from the graph, nodes, and edges are not copied to the new
    graph.
    z.cannot apply intersection_all to an empty list)r   r   r   r	   Úintersection)r   ÚRr   r   r   r   r   „   s    
©N)r   )
Ú__doc__Ú	itertoolsr   Znetworkxr	   Ú__all__r   r   r   r   r   r   r   r   Ú<module>   s   
0%&