ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Reductions.h File Reference

The polynomial reductions of chapter 18: a function \( f \) from the inputs of \( A \) to the inputs of \( B \), computable in polynomial time, such that \( x \) is a YES of \( A \) if and only if \( f( x ) \) is a YES of \( B \); then \( A \) is no harder than \( B \) (\( A \propto B \)). More...

#include "ADS/Contract.h"
#include "ADS/complexity/Domino.h"
#include "ADS/complexity/Problems.h"
#include "ADS/geometry/ConvexHull.h"
#include <array>
#include <cstddef>
#include <limits>
#include <numeric>
#include <tuple>
#include <utility>
#include <vector>
#include "ADS/complexity/impl/Reductions.tpp"

Go to the source code of this file.

Namespaces

namespace  ADS

Functions

int ADS::tileVar (int h, int i, int j, int n)
 the place \( ( h n + i ) n + j \) of the variable or node of the tile \( h \) in the square \( ( i , j ) \)
std::pair< Adjacency, int > ADS::dominoToClique (const std::vector< Tile > &D, int n)
 BOUNDED TILING to CLIQUE: the graph on the \( m n^2 \) places of tileVar(), the ones of \( ( 0 , 0 ) \) but \( u_{000} \) isolated, and \( k \).
Cnf ADS::dominoToSat (const std::vector< Tile > &D, int n)
 BOUNDED TILING to SATISFIABILITY, on the \( m n^2 \) variables of tileVar().
std::pair< std::vector< std::vector< long > >, std::vector< long > > ADS::dominoToLp01 (const std::vector< Tile > &D, int n)
 BOUNDED TILING to 0-1 INTEGER PROGRAMMING: \( A x \le b \) on the \( m n^2 \) variables of tileVar(), each equation as two inequalities.
Adjacency ADS::complement (const Adjacency &G)
 the complement graph: CLIQUE of size \( k \) to INDEPENDENT SET of size \( k \)
std::vector< std::vector< long > > ADS::hamiltonToTsp (const Adjacency &G)
 HAMILTONIAN CIRCUIT to TRAVELING SALESMAN: the distances, \( k = n \).
long ADS::halfSum (const std::vector< long > &A)
 half the sum, or \( -1 \) if the sum is odd (then no partition: the bound \( -1 \) has no YES in any of the three problems)
Adjacency ADS::cycleToPath (const Adjacency &G)
 DIRECTED HAMILTONIAN CIRCUIT to DIRECTED HAMILTONIAN PATH from \( n \) to 0: the node 0 split, a new node \( n \) with the edges out of 0; the loops of \( G \) dropped, as the problems of Problems.h ignore them.
Adjacency ADS::cycleToChain (const Adjacency &G)
 DIRECTED HAMILTONIAN CIRCUIT to HAMILTONIAN PATH: the path of cycleToPath(), each node \( v \) a chain \( v_{in} - v_{mid} - v_{out} \), each edge \( ( u , v ) \) an edge \( [ u_{out} , v_{in} ] \), and pendant nodes at the start and at the end.
std::vector< Point > ADS::sortToHull (const std::vector< long > &a)
 SORTING to CONVEX HULL: the points \( ( a , a^2 ) \).

Detailed description

The polynomial reductions of chapter 18: a function \( f \) from the inputs of \( A \) to the inputs of \( B \), computable in polynomial time, such that \( x \) is a YES of \( A \) if and only if \( f( x ) \) is a YES of \( B \); then \( A \) is no harder than \( B \) (\( A \propto B \)).

  • BOUNDED TILING to CLIQUE (Theorem 18.2): a node \( u_{hij} \) for the tile \( h \) in the square \( ( i , j ) \), only \( u_{000} \) in \( ( 0 , 0 ) \), joined to the nodes of the squares not adjacent and to those of the adjacent squares whose tile fits, and \( k = n^2 \);
  • BOUNDED TILING to SATISFIABILITY (Theorem 18.3): \( u_{000} \), a tile at least and one at most in each square, and no two tiles that do not fit side by side;
  • BOUNDED TILING to 0-1 INTEGER PROGRAMMING (Theorem 18.4): \( x_{000} = 1 \), one tile per square, and \( x_{hij} \) plus the tiles that do not fit next to it at most 1 (the example of the text writes one inequality per pair, which is the same since a square holds one tile);
  • CLIQUE to INDEPENDENT SET (Theorem 18.5), the complement graph; INDEPENDENT SET to VERTEX COVER (exercise 18.11), the complement of a set is a cover, \( k' = n - k \);
  • HAMILTONIAN CIRCUIT to TRAVELING SALESMAN (Theorem 18.6): the distance 1 on the edges and 2 elsewhere, \( k = n \);
  • PARTITION to MULTIPROCESSOR SCHEDULING, SUBSET SUM and KNAPSACK (Theorems 18.7 to 18.9), half of the sum as the bound;
  • HAMILTONIAN CIRCUIT to DIRECTED HAMILTONIAN CIRCUIT (exercise 18.12), both the orientations of each edge; DIRECTED HAMILTONIAN CIRCUIT to DIRECTED HAMILTONIAN PATH (exercise 18.13), the node 0 split into a start with its edges out and an end with its edges in; DIRECTED HAMILTONIAN CIRCUIT to HAMILTONIAN PATH (exercise 18.14), that path with each node made a chain of three and a pendant node at each end;
  • DIRECTED HAMILTONIAN PATH from \( r \) to \( t \) to LONGEST PATH, \( k = n - 1 \), and HAMILTONIAN PATH to DEGREE-CONSTRAINED SPANNING TREE, \( k = 2 \) (exercises 18.15 and 18.16);
  • SORTING to CONVEX HULL: the points \( ( a_i , a_i^2 ) \) on the parabola are all vertices of the hull, in the order of the \( a_i \), so the hull costs \( \Omega( n \log n ) \).

The contracts [see Contract.h]: each reduction checks that its input is an instance of the problem reduced (a square or unoriented graph, a nonempty set of tiles, numbers not negative) and that its output has the shape of an instance of the target problem. The operations are defined in Reductions.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, sections 18.5 and 18.7, https://algoritmicamente.it/materiali/libro/capitoli/cap18.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa