tqec.computation.conversion.convert_zx_graph_to_block_graph#

convert_zx_graph_to_block_graph(zx_graph: ZXGraph, name: str | None = None) BlockGraph[source]#

Convert the ZX graph to a block graph.

The ZX graph includes the minimal information required to construct the block graph, but is not guaranteed to admit a valid block structure. The block structure will be inferred from the ZX graph and validated.

The conversion process is as follows:

  1. Construct cubes for all the corner nodes in the ZX graph.

  2. Construct pipes connecting ports/Y to ports/Y nodes.

  3. Greedily construct the pipes until no more pipes can be inferred.

  4. If there are still nodes left, then choose orientation for an arbitrary node and repeat 3. Repeat 4 until all nodes are handled or conflicts are detected.

Parameters:
  • zx_graph – The base ZX graph to construct the block graph.

  • name – The name of the new block graph. If None, the name of the ZX graph will be used.

Returns:

The constructed block graph.