state#

Quantum states

Classes

GraphState([nodes_state, state, edges, nodes])

A graph state composed by several SubGraphStates.

SubGraphState([nodes_state, state, edges, nodes])

A subgraph state of a quantum state.

class GraphState(nodes_state: int | list[int] | None = None, state: Any = 'plus', edges: list | None = None, nodes: int | list[int] | None = None)[source]#

Bases: Module

A graph state composed by several SubGraphStates.

Parameters:
  • nodes_state (int | list[int] | None) – The nodes of the input state in the initial graph state. It can be an integer representing the number of nodes or a list of node indices. Default: None

  • state (Any) – The input state of the initial graph state. The string representation of state could be 'plus', 'minus', 'zero', and 'one'. Default: 'plus'

  • edges (list | None) – Additional edges connecting the nodes in the initial graph state. Default: None

  • nodes (int | list[int] | None) – Additional nodes to include in the initial graph state. Default: None

add_subgraph(nodes_state: int | list[int] | None = None, state: Any = 'plus', edges: list | None = None, nodes: int | list[int] | None = None, measure_dict: dict | None = None, index: int | None = None) None[source]#

Add a subgraph state to the graph state.

Parameters:
  • nodes_state (int | list[int] | None) – The nodes of the input state in the subgraph state. It can be an integer representing the number of nodes or a list of node indices. Default: None

  • state (Any) – The input state of the subgraph state. The string representation of state could be 'plus', 'minus', 'zero', and 'one'. Default: 'plus'

  • edges (list | None) – Additional edges connecting the nodes in the subgraph state. Default: None

  • nodes (int | list[int] | None) – Additional nodes to include in the subgraph state. Default: None

  • measure_dict (dict | None) – A dictionary containing all measurement results. Default: None

  • index (int | None) – The index where to insert the subgraph state. Default: None

property full_state: Tensor#

Compute and return the full quantum state of the graph state.

property graph: SubGraphState#

The combined graph state of all subgraph states.

property measure_dict: dict#

A dictionary containing all measurement results for the graph state.

set_nodes_out_seq(nodes: list[int] | None = None) None[source]#

Set the output sequence of the nodes.

class SubGraphState(nodes_state: int | list[int] | None = None, state: Any = 'plus', edges: list | None = None, nodes: int | list[int] | None = None)[source]#

Bases: Module

A subgraph state of a quantum state.

Parameters:
  • nodes_state (int | list[int] | None) – The nodes of the input state in the subgraph state. It can be an integer representing the number of nodes or a list of node indices. Default: None

  • state (Any) – The input state of the subgraph state. The string representation of state could be 'plus', 'minus', 'zero', and 'one'. Default: 'plus'

  • edges (list | None) – Additional edges connecting the nodes in the subgraph state. Default: None

  • nodes (int | list[int] | None) – Additional nodes to include in the subgraph state. Default: None

add_edges(edges: list) None[source]#

Add edges to the subgraph state.

add_nodes(nodes: int | list[int]) None[source]#

Add nodes to the subgraph state.

compose(other: SubGraphState, relabel: bool = True) SubGraphState[source]#

Compose this subgraph state with another subgraph state.

Parameters:
  • other (SubGraphState) – The other subgraph state to compose with.

  • relabel (bool) – Whether to relabel nodes to avoid conflicts. Default: True

Returns:

A new subgraph state that is the composition of the two.

Return type:

SubGraphState

draw(**kwargs)[source]#

Draw the graph using NetworkX.

property edges#

Edges of the graph.

extra_repr() str[source]#
property full_state: Tensor#

Compute and return the full quantum state of the subgraph state.

property nodes#

Nodes of the graph.

set_graph(nodes_state: int | list[int] | None = None, edges: list | None = None, nodes: int | list[int] | None = None) None[source]#

Set the graph structure for the subgraph state.

set_nodes_out_seq(nodes: list[int] | None = None) None[source]#

Set the output sequence of the nodes.

set_state(state: Any = 'plus') None[source]#

Set the input state of the subgraph state.

shift_labels(n: int) None[source]#

Shift the labels of the nodes in the graph by a given integer.

update_node2wire_dict() dict[source]#

Update the mapping from nodes to wire indices.

Returns:

A dictionary mapping nodes to their corresponding wire indices.

Return type:

dict