Skip to main content

impl_variant_reduction

Macro impl_variant_reduction 

Source
macro_rules! impl_variant_reduction {
    ($problem:ident,
     < $($src_param:ty),+ > => < $($dst_param:ty),+ >,
     fields: [$($field:ident),+],
     |$src:ident| $body:expr) => { ... };
}
Expand description

Generates a variant-cast ReduceTo impl with #[reduction] registration.

Variant casts convert a problem from one variant to another (e.g., MIS<KingsSubgraph, i32> -> MIS<UnitDiskGraph, i32>). The solution mapping is identity – vertex/element indices are preserved.

The problem name is specified once, followed by <SourceParams> => <TargetParams>. This works with any number of type parameters.

§Example

impl_variant_reduction!(
    MaximumIndependentSet,
    <KingsSubgraph, i32> => <UnitDiskGraph, i32>,
    fields: [num_vertices, num_edges],
    |src| MaximumIndependentSet::new(
        src.graph().cast_to_parent(), src.weights())
);