# Algorithm for designing a binary code with predefined distance

Suppose I have a matrix $A$ with its entry $A_{ij}$ denoting some kind of distance between class $i$ and $j$, is there a feasible algorithm for computing a binary coding for all the classes, such that the Hamming distance between code word for $i$ and $j$ is (roughly) proportional to $A_{ij}$?

A related question is that given a set of points, design a binary code where the Hamming distance is (roughly) proportional to the Euclidean distance.

This is known as an embedding into $\{0,1\}^n$. Your matrix $A$ defines a weighted graph, and you want an embedding into the hypercube.