Code graph functions
Functions to access and manipulate the CodeGraph
associated with a TensorNetworkCode
.
Introductory notes
- Node labels are of type
Int
with negative and positive integers representing virtual nodes and physical qubits, respectively. - Edge labels are of type
Set{Int}
and contain two elements corresponding to the labels of the nodes that the edge links. - Node coordinates are of type
Vector{<:Real}
and contain two elements corresponding to 2-dimensional Cartesian coordinates. - Node types are of type
String
and can take the values: "physical" for physical qubits or else they take the name of a seed code for virtual nodes, e.g., "Five qubit code". - Edge types are of type
String
and can take the values: "physical" for an edge between a virtual node and physical (i.e., qubit) node or "bond" for an edge between two virtual nodes, e.g., as occurs after contracting a "Five qubit code" and a "Steane code". - Edge indices are of type
Vector{ITensors.Index{Int64}}}
. These are lists of the indices necessary for tensor-network contraction (e.g., for decoding). - Node indices are also of type
Vector{ITensors.Index{Int64}}}
. These indices match the indices on the incident edges to that node. This is necessary for, e.g., tensor-network decoding: when a tensor is created at a node, the first index in the list of node indices corresponds to the first qubit of the seed code, and so on.
Specialized functions
TensorNetworkCodes.edges
— Functionedges(code) -> Vector{Set{Int}}
Returns a list of edge labels for the code, corresponding to edges between nodes.
TensorNetworkCodes.new_indices
— Functionnew_indices(code::TensorNetworkCode) -> TensorNetworkCode
Deepcopies the code but changes all ITensor
indices.
TensorNetworkCodes.nodes
— Functionnodes(code::TensorNetworkCode) -> Vector{Int}
Returns an ordered list of node labels for the code, corresponding to the qubits and virtual nodes.
TensorNetworkCodes.num_nodes
— Functionnum_nodes(code::TensorNetworkCode) -> Int
Returns the number of nodes in the code, which is the sum of the number of qubits and the number of virtual nodes.
TensorNetworkCodes.physical_neighbours
— Functionphysical_neighbours(code::TensorNetworkCode, node::Int) -> Set{Int}
Returns the node labels of physical qubits connected by an edge to the given node.
TensorNetworkCodes.set_coords!
— Methodset_coords!(
code::TensorNetworkCode,
new_coords::AbstractVector{<:AbstractVector{<:Real}}
)
Assign new coordinates to all (physical and virtual) nodes of the code, where the order of the coordinates matches that of the nodes returned by nodes
, i.e. in ascending order.
TensorNetworkCodes.shift_coords!
— Methodshift_coords!(code::TensorNetworkCode, shift::AbstractVector{<:Real})
Shift the coordinates of all (physical and virtual) nodes of the code by the given shift.
Generic getters / setters
TensorNetworkCodes.coords
— Functioncoords(code::TensorNetworkCode)
Return coords
field of the code's CodeGraph
.
coords(code::TensorNetworkCode, label::Int)
Return coords[label]
for the node from the code's CodeGraph
.
TensorNetworkCodes.set_coords!
— Methodset_coords!(code::TensorNetworkCode, label::Int, new_data)
Set coords[label]
for the node from the code's CodeGraph
.
TensorNetworkCodes.edge_indices
— Functionedge_indices(code::TensorNetworkCode)
Return edge_indices
field of the code's CodeGraph
.
edge_indices(code::TensorNetworkCode, label::Set{Int})
Return edge_indices[label]
for the edge from the code's CodeGraph
.
TensorNetworkCodes.set_edge_indices!
— Functionset_edge_indices!(code::TensorNetworkCode, label::Set{Int}, new_data)
Set edge_indices[label]
for the edge from the code's CodeGraph
.
TensorNetworkCodes.edge_types
— Functionedge_types(code::TensorNetworkCode)
Return edge_types
field of the code's CodeGraph
.
edge_types(code::TensorNetworkCode, label::Set{Int})
Return edge_types[label]
for the edge from the code's CodeGraph
.
TensorNetworkCodes.set_edge_types!
— Functionset_edge_types!(code::TensorNetworkCode, label::Set{Int}, new_data)
Set edge_types[label]
for the edge from the code's CodeGraph
.
TensorNetworkCodes.node_indices
— Functionnode_indices(code::TensorNetworkCode)
Return node_indices
field of the code's CodeGraph
.
node_indices(code::TensorNetworkCode, label::Int)
Return node_indices[label]
for the node from the code's CodeGraph
.
TensorNetworkCodes.set_node_indices!
— Functionset_node_indices!(code::TensorNetworkCode, label::Int, new_data)
Set node_indices[label]
for the node from the code's CodeGraph
.
TensorNetworkCodes.node_types
— Functionnode_types(code::TensorNetworkCode)
Return node_types
field of the code's CodeGraph
.
node_types(code::TensorNetworkCode, label::Int)
Return node_types[label]
for the node from the code's CodeGraph
.
TensorNetworkCodes.set_node_types!
— Functionset_node_types!(code::TensorNetworkCode, label::Int, new_data)
Set node_types[label]
for the node from the code's CodeGraph
.