tket
|
Intended for use with TokenSwapping. More...
#include <ArchitectureMapping.hpp>
Public Member Functions | |
ArchitectureMapping (const Architecture &arch) | |
The object must remain valid and unchanged throughout the life of this object. | |
ArchitectureMapping (const Architecture &arch, const std::vector< std::pair< unsigned, unsigned > > &edges) | |
If the architecture object was initialised with explicit edges, use these edges (rather than the Architecture nodes() function) to create the Node <-> size_t mapping, in a fixed way not dependent on Architecture (the reason being that Architecture does not guarantee the mapping, but if we change the labels then we change to an isomorphic but different token swapping problem, which messes up testing. | |
const Architecture & | get_architecture () const |
Convenient reference to the Architecture object we used to construct this ArchitectureMapping. | |
std::size_t | number_of_vertices () const |
The number of vertices in the Architecture. | |
std::size_t | get_vertex (const Node &node) const |
Get the newly created vertex assigned to the node. | |
const Node & | get_node (std::size_t vertex) const |
Reverse of "get_vertex", throws if the vertex is invalid. | |
std::vector< Swap > | get_edges () const |
Get the edges using the vertices created by this ArchitectureMapping object. | |
Intended for use with TokenSwapping.
For mapping between nodes in an architecture and size_t vertex numbers. The vertex numbers are merely the indices of each Node within the vector returned by the get_all_nodes() function.
For now, we don't want to use Node objects as (1) this would make TokenSwapping dependent on other parts of Tket and hence less modular, (2) it would probably slow things down significantly because Nodes contain extra data, like vectors and strings, which are relatively expensive to copy; vertices get copied and moved around many times by any TSA.
TODO: it would be better to use a Vertex wrapper class instead of raw size_t. (Also, might change to unsigned instead of size_t).
Definition at line 38 of file ArchitectureMapping.hpp.
|
explicit |
The object must remain valid and unchanged throughout the life of this object.
arch | The finished Architecture object, must remain valid for the lifetime of this object. |
Definition at line 21 of file ArchitectureMapping.cpp.
tket::ArchitectureMapping::ArchitectureMapping | ( | const Architecture & | arch, |
const std::vector< std::pair< unsigned, unsigned > > & | edges | ||
) |
If the architecture object was initialised with explicit edges, use these edges (rather than the Architecture nodes() function) to create the Node <-> size_t mapping, in a fixed way not dependent on Architecture (the reason being that Architecture does not guarantee the mapping, but if we change the labels then we change to an isomorphic but different token swapping problem, which messes up testing.
In practice every implementation of token swapping, except for the ultimate probably exponential-time optimal algorithm, is going to depend on the labels. Even if we had a fast graph isomorphism routine, the labels would still not be uniquely determined, as they could be permuted).
arch | The finished Architecture object, must remain valid for the lifetime of this object. |
edges | Edges originally used to construct the Architecture object. These will uniquely determine the internal Node <-> size_t mapping. |
Definition at line 44 of file ArchitectureMapping.cpp.
const Architecture & tket::ArchitectureMapping::get_architecture | ( | ) | const |
Convenient reference to the Architecture object we used to construct this ArchitectureMapping.
Definition at line 118 of file ArchitectureMapping.cpp.
std::vector< Swap > tket::ArchitectureMapping::get_edges | ( | ) | const |
Get the edges using the vertices created by this ArchitectureMapping object.
The vertex numbers, of course, do not necessarily match with the Node uids of the underlying architecture object (that's why we have a mapping).
Definition at line 122 of file ArchitectureMapping.cpp.
const Node & tket::ArchitectureMapping::get_node | ( | std::size_t | vertex | ) | const |
Reverse of "get_vertex", throws if the vertex is invalid.
vertex | The vertex created by this ArchitectureMapping object. |
Definition at line 96 of file ArchitectureMapping.cpp.
std::size_t tket::ArchitectureMapping::get_vertex | ( | const Node & | node | ) | const |
Get the newly created vertex assigned to the node.
Throws if the node is invalid.
node | The node within the original Architecture object |
Definition at line 108 of file ArchitectureMapping.cpp.
std::size_t tket::ArchitectureMapping::number_of_vertices | ( | ) | const |
The number of vertices in the Architecture.
Definition at line 92 of file ArchitectureMapping.cpp.