Skip to main content

reduction

Attribute Macro reduction 

Source
#[reduction]
Expand description

Attribute macro for automatic reduction registration.

This macro parses a ReduceTo impl block and automatically generates the corresponding inventory::submit! call with the correct metadata.

§Type Parameter Convention

The macro extracts graph and weight type information from type parameters:

  • Problem<G> where G is a graph type - extracts graph type name
  • Problem<G, W> where W is a weight type - weighted if W != Unweighted

§Example

#[reduction(
    source_graph = "SimpleGraph",
    target_graph = "GridGraph",
    source_weighted = false,
    target_weighted = true,
)]
impl ReduceTo<IndependentSet<i32, GridGraph>> for IndependentSet<Unweighted, SimpleGraph> {
    type Result = ReductionISToGridIS;
    fn reduce_to(&self) -> Self::Result { ... }
}

The macro also supports inferring from type names when explicit attributes aren’t provided.