Generalization of piece-wise linear functions over a metric space Suppose we want to construct a function $f$ from a compact metric space $(X,\rho)$ to a Euclidean space $\mathbb{R}^n$ that is Lipschitz continuous with a constant $L$:
$$ \forall x,y \in X . ||f(x)-f(y)|| \leq L \cdot \rho(x, y) $$ 
Suppose that there is a sequence of unequal points $\{x_1,...x_N\}$ in $X$ such that all metrics $\rho(x_i,x_j)$ are known and $f(x_i)=a_i$ for some $a_i$ in $\mathbb{R}^n$ whereas:
$$ \forall x_i,x_j \in \{x_1,...x_N\} . ||a_i-a_j|| \leq L \cdot \rho(x_i, x_j) $$
Suppose also that $\{x_1,...x_N\}$ form a finite cover of $X$ by balls of some suitable (known) radius.
Is there any way to construct $f$ for all the points in $X$ so that it's Lipschitz continuous with a constant $L$?

My first idea was to use something like:
$$f(x):=f\left(x_{i}\right)+\left(f\left(x_{j}\right)-f\left(x_{i}\right)\right)\cdot\dfrac{\rho\left(x,x_{i}\right)}{\rho\left(x_{i},x_{j}\right)}$$
But it only works for the points "between" $x_i$ and $x_j$, and there may be other points of the net that interfere.

The question has been also posted here since there might be some research potential.
 A: Consider the functions $$g_i(x) = \prod_{j\ne i} \frac{\rho(x,x_j)}{\rho(x_i,x_j)}$$
And let $f(x) = \sum_i a_ig_i(x)$. This gives you a function with the right values. I haven't verified if it satisfies the Lipschitz condition, though.
A: I will only consider $a_i\in\mathbb R$. (So this does not answer the original question. This is reaction to the OP's request in this comment.)
Things we will need to know:


*

*If $A,B\subseteq X$ are closed subsets of a metric space $X$ such that $\rho(A,B)>0$, then there exists a Lipschitz function $f\colon X\to\mathbb R$ such that $f|_A=1$ and $f|_B=0$. An example of such function is $f(x)=\frac{\rho(x,B)}{\rho(x,A)+\rho(x,B)}$. See, for example: Urysohn's lemma with Lipschitz functions

*Sum of two Lipschitz functions is Lipschitz. See: sum and product of Lipschitz functions
Using the above fact we can do the following:
Taking $A=\{x_i\}$ and $B=\{x_1,\dots,x_{i-1},x_{i+1},\dots,x_N\}$ we have a Lipschitz function such that
$$f_i(x_j)=\delta_{ij}=
  \begin{cases}
    1 & \text{if }i=j, \\
    0 & \text{if }i\ne j.
  \end{cases}
$$
If we take the function
$$f(x)=\sum_{i=1}^N a_if_i(x),$$
then the function has the required properties.


*

*We have $f(x_j)= \sum_{i=1}^N a_if_i(x_j) = a_jf_j(x_j) = a_j$.

*It is a Lipschitz function, since it is a linear combination of finitely many Lipschitz function. (And finite sums and constant multiples of Lipschitz functions are again Lipschitz.)

A: This can even be done into $\Bbb{R}$.  Observe $\rho(\cdot, x_1)$ is Lipschitz with constant $1$ and $a_1 + L \rho(\cdot,x_1)$ is Lipschitz with constant $L$.  In fact, any suitably Lipschitz function lying in $a_1 + [-L \rho(\cdot, x_1), L \rho(\cdot, x_1)]$ works.  Your second display relation says that the intersection of all these regions is nonempty.  Consequently, the extremal constraint is $$
    f(x) \in [\max_j a_j - L \rho(x,x_j), \min_j a_j + L \rho(x,x_j)]
$$ and there are rather a lot of Lipschitz continuous functions that globally satisfy this constraint.  In the multidimensional case, this becomes $f(x) \in$ the intersection of $N$ spheres, but again your second display relation and the triangle inequality shows this intersection is nonempty.
Those maxima and minima are (uniformly) continuous functions of $x$, so an easy function to write is $f(x) = \frac{1}{2} ( (\max_j a_j - L \rho(x,x_j)) + (\min_j a_j + L \rho(x,x_j) ))$, which is (uniformly) continuous.
