pub struct MappingResult<T = KsgTapeEntry> {
pub positions: Vec<(i32, i32)>,
pub node_weights: Vec<i32>,
pub grid_dimensions: (usize, usize),
pub kind: GridKind,
pub lines: Vec<CopyLine>,
pub padding: usize,
pub spacing: usize,
pub mis_overhead: i32,
pub tape: Vec<T>,
pub doubled_cells: HashSet<(usize, usize)>,
}Expand description
Result of mapping a graph to a grid graph.
Fields§
§positions: Vec<(i32, i32)>Integer grid positions (row, col) for each node.
node_weights: Vec<i32>Weight of each node.
grid_dimensions: (usize, usize)Grid dimensions (rows, cols).
kind: GridKindThe kind of grid lattice.
lines: Vec<CopyLine>Copy lines used in the mapping.
padding: usizePadding used.
spacing: usizeSpacing used.
mis_overhead: i32MIS overhead from the mapping.
tape: Vec<T>Tape entries recording gadget applications (for unapply during solution extraction).
doubled_cells: HashSet<(usize, usize)>Doubled cells (where two copy lines overlap) for map_config_back.
Implementations§
Source§impl<T> MappingResult<T>
impl<T> MappingResult<T>
Sourcepub fn num_original_vertices(&self) -> usize
pub fn num_original_vertices(&self) -> usize
Get the number of vertices in the original graph.
Sourcepub fn print_config(&self, config: &[Vec<usize>])
pub fn print_config(&self, config: &[Vec<usize>])
Print a configuration on the grid, highlighting selected nodes.
Characters:
.= empty cell (no grid node at this position)*= selected node (config != 0)o= unselected node (config == 0)
Sourcepub fn format_config(&self, config: &[Vec<usize>]) -> String
pub fn format_config(&self, config: &[Vec<usize>]) -> String
Format a 2D configuration as a string.
Sourcepub fn print_config_flat(&self, config: &[usize])
pub fn print_config_flat(&self, config: &[usize])
Print a flat configuration vector on the grid.
Sourcepub fn format_config_flat(&self, config: &[usize]) -> String
pub fn format_config_flat(&self, config: &[usize]) -> String
Format a flat configuration vector as a string.
Sourcepub fn to_kings_subgraph(&self) -> KingsSubgraph
pub fn to_kings_subgraph(&self) -> KingsSubgraph
Create a KingsSubgraph from this mapping result, extracting positions
and discarding weights.
Sourcepub fn to_triangular_subgraph(&self) -> TriangularSubgraph
pub fn to_triangular_subgraph(&self) -> TriangularSubgraph
Create a TriangularSubgraph from this mapping result, extracting positions
and discarding weights.
Source§impl MappingResult<KsgTapeEntry>
impl MappingResult<KsgTapeEntry>
Sourcepub fn map_config_back(&self, grid_config: &[usize]) -> Vec<usize>
pub fn map_config_back(&self, grid_config: &[usize]) -> Vec<usize>
Map a configuration back from grid to original graph.
This follows the algorithm:
- Convert flat grid config to 2D matrix
- Unapply gadgets in reverse order (modifying config matrix)
- Extract vertex configs from copyline locations
§Arguments
grid_config- Configuration on the grid graph (0 = not selected, 1 = selected)
§Returns
A vector where result[v] is 1 if vertex v is selected, 0 otherwise.
Sourcepub fn map_config_back_via_centers(&self, grid_config: &[usize]) -> Vec<usize>
pub fn map_config_back_via_centers(&self, grid_config: &[usize]) -> Vec<usize>
Map a configuration back from grid to original graph using center locations.
Source§impl MappingResult<WeightedKsgTapeEntry>
impl MappingResult<WeightedKsgTapeEntry>
Sourcepub fn map_config_back(&self, grid_config: &[usize]) -> Vec<usize>
pub fn map_config_back(&self, grid_config: &[usize]) -> Vec<usize>
Map a configuration back from grid to original graph (weighted version).
Trait Implementations§
Source§impl<T: Clone> Clone for MappingResult<T>
impl<T: Clone> Clone for MappingResult<T>
Source§fn clone(&self) -> MappingResult<T>
fn clone(&self) -> MappingResult<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for MappingResult<T>
impl<T: Debug> Debug for MappingResult<T>
Source§impl<'de, T> Deserialize<'de> for MappingResult<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for MappingResult<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> Display for MappingResult<T>
impl<T> Display for MappingResult<T>
Auto Trait Implementations§
impl<T> Freeze for MappingResult<T>
impl<T> RefUnwindSafe for MappingResult<T>where
T: RefUnwindSafe,
impl<T> Send for MappingResult<T>where
T: Send,
impl<T> Sync for MappingResult<T>where
T: Sync,
impl<T> Unpin for MappingResult<T>where
T: Unpin,
impl<T> UnwindSafe for MappingResult<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.