# 65.31 MinimumDistance

`MinimumDistance( C )`

`MinimumDistance` returns the minimum distance of C, the largest integer d with the property that every element of C has at least a Hamming distance d (see DistanceCodeword) to any other element of C. For linear codes, the minimum distance is equal to the minimum weight. This means that d is also the smallest positive value with w[d+1] neq 0, where w is the weight distribution of C (see WeightDistribution). For unrestricted codes, d is the smallest positive value with w[d+1] neq 0, where w is the inner distribution of C (see InnerDistribution).

For codes with only one element, the minimum distance is defined to be equal to the word length.

```    gap> C := MOLSCode(7);; MinimumDistance(C);
3
gap> WeightDistribution(C);
[ 1, 0, 0, 24, 24 ]
gap> MinimumDistance( WholeSpaceCode( 5, GF(3) ) );
1
gap> MinimumDistance( NullCode( 4, GF(2) ) );
4
gap> C := ConferenceCode(9);; MinimumDistance(C);
4
gap> InnerDistribution(C);
[ 1, 0, 0, 0, 63/5, 9/5, 18/5, 0, 9/10, 1/10 ] ```

`MinimumDistance( C, w )`

In this form, `MinimumDistance` returns the minimum distance of a codeword w to the code C, also called the distance to C. This is the smallest value d for which there is an element c of the code C which is at distance d from w. So d is also the minimum value for which D[d+1] neq 0, where D is the distance distribution of w to C (see DistancesDistribution).

Note that w must be an element of the same vector space as the elements of C. w does not necessarily belong to the code (if it does, the minimum distance is zero).

```    gap> C := MOLSCode(7);; w := CodewordNr( C, 17 );
[ 2 2 4 6 ]
gap> MinimumDistance( C, w );
0
gap> C := RemovedElementsCode( C, w );; MinimumDistance( C, w );
3                           # so w no longer belongs to C ```

GAP 3.4.4
April 1997