tket
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tket::ArchitectureMapping Class Reference

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 Architectureget_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 Nodeget_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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ArchitectureMapping() [1/2]

tket::ArchitectureMapping::ArchitectureMapping ( const Architecture arch)
explicit

The object must remain valid and unchanged throughout the life of this object.

Parameters
archThe finished Architecture object, must remain valid for the lifetime of this object.

Definition at line 21 of file ArchitectureMapping.cpp.

◆ ArchitectureMapping() [2/2]

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).

Parameters
archThe finished Architecture object, must remain valid for the lifetime of this object.
edgesEdges 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.

Member Function Documentation

◆ get_architecture()

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.

◆ get_edges()

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).

Returns
The vector of edges in the architecture, using the new vertex numbers.

Definition at line 122 of file ArchitectureMapping.cpp.

◆ get_node()

const Node & tket::ArchitectureMapping::get_node ( std::size_t  vertex) const

Reverse of "get_vertex", throws if the vertex is invalid.

Parameters
vertexThe vertex created by this ArchitectureMapping object.
Returns
The node corresponding to this vertex.

Definition at line 96 of file ArchitectureMapping.cpp.

◆ get_vertex()

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.

Parameters
nodeThe node within the original Architecture object
Returns
The newly created vertex representing this node

Definition at line 108 of file ArchitectureMapping.cpp.

◆ number_of_vertices()

std::size_t tket::ArchitectureMapping::number_of_vertices ( ) const

The number of vertices in the Architecture.

Returns
The number of vertices

Definition at line 92 of file ArchitectureMapping.cpp.


The documentation for this class was generated from the following files: