#NEWLINE# def lexicographic_product( G , H ) : #NEWLINE# #INDENT# "Return the lexicographic product of G and H.\n\n    The lexicographical product P of the graphs G and H has a node set that\n    is the Cartesian product of the node sets, $V(P)=V(G) \times V(H)$.\n    P has an edge ((u,v),(x,y)) if and only if (u,v) is an edge in G \n    or u==v and (x,y) is an edge in H.\n\n    Parameters\n    ----------\n    G, H: graphs\n     Networkx graphs. \n\n    Returns\n    -------\n    P: NetworkX graph\n     The Cartesian product of G and H. P will be a multi-graph if either G\n     or H is a multi-graph. Will be a directed if G and H are directed,\n     and undirected if G and H are undirected.\n\n    Raises\n    ------\n    NetworkXError\n     If G and H are not both directed or both undirected.\n\n    Notes\n    -----\n    Node attributes in P are two-tuple of the G and H node attributes.\n    Missing attributes are assigned None.\n\n    For example\n    >>> G = nx.Graph()\n    >>> H = nx.Graph()\n    >>> G.add_node(0,a1=True)\n    >>> H.add_node('a',a2='Spam')\n    >>> P = nx.lexicographic_product(G,H)\n    >>> P.nodes()\n    [(0, 'a')]\n\n    Edge attributes and edge keys (for multigraphs) are also copied to the\n    new product graph\n    " #NEWLINE# GH = _init_product_graph ( G , H ) #NEWLINE# GH . add_nodes_from ( _node_product ( G , H ) ) #NEWLINE# GH . add_edges_from ( _edges_cross_nodes_and_nodes ( G , H ) ) #NEWLINE# GH . add_edges_from ( _nodes_cross_edges ( G , H ) ) #NEWLINE# GH . name = ( ( ( ( 'Lexicographic product(' + G . name ) + ',' ) + H . name ) + ')' ) #NEWLINE# return GH