rustworkx.cartesian_productΒΆ
- cartesian_product(first, second)[source]ΒΆ
Return a new graph by forming the cartesian product from two input graph objects
- Parameters:
first β The first graph object
second β The second graph object
- Returns:
A new graph object that is the union of
secondandfirst. Itβs worth noting the weight/data payload objects are passed by reference fromfirstandsecondto this new object. A read-only dictionary of the product of nodes is also returned. The keys are a tuple where the first element is a node of the first graph and the second element is a node of the second graph, and the values are the map of those elements to node indices in the product graph. For example:{ (0, 0): 0, (0, 1): 1, }
- Return type:
Tuple[
PyGraphorPyDiGraph,ProductNodeMap]