Return the lexicographic product of G and H.
The lexicographical product P of the graphs G and H has a node set that is the Cartesian product of the node sets, $V(P)=V(G) imes V(H)$. P has an edge ((u,v),(x,y)) if and only if (u,v) is an edge in G or u==v and (x,y) is an edge in H.
Parameters : | G, H: graphs :
|
---|---|
Returns : | P: NetworkX graph :
|
Raises : | NetworkXError :
|
Notes
Node attributes in P are two-tuple of the G and H node attributes. Missing attributes are assigned None.
For example >>> G = nx.Graph() >>> H = nx.Graph() >>> G.add_node(0,a1=True) >>> H.add_node(‘a’,a2=’Spam’) >>> P = nx.tensor_product(G,H) >>> P.nodes(data=True) [((0, ‘a’), {‘a1’: (True, None), ‘a2’: (None, ‘Spam’)})]
Edge attributes and edge keys (for multigraphs) are also copied to the new product graph