A method and apparatus are disclosed that compress an input string to an
equivalent word relative to a noncommutation graph. The disclosed
compression system compresses an input string in a manner that an
equivalent string is produced upon decompression. The disclosed
compression algorithms are based upon normal forms. First, a normal form
of the interchange class is produced containing the source output string.
Thereafter, a grammar-based lossless data compression scheme (or another
compression scheme) is applied to the normal form. Upon decompression,
the compressed string produces an equivalent string. A normal form
generation process is employed to compute the lexicographic normal form
or the Foata normal form of an interchange class from one of its members,
using only a single pass over the data.