TITLE: Diameter of a weighted Hamming cube
QUESTION [7 upvotes]: Let $C=(\mathbb{Z}/2\mathbb{Z})^N$ be the Hamming cube with its usual graph structure, and assume each edge $e=(x,x+\epsilon)$ (where $x\in C$ and $\epsilon$ has one $1$ and $N-1$ zeros) is given a length $\ell(x,\epsilon)$ satisfying the constraints
$$ \sum_\epsilon \ell(x,\epsilon) \le 1 \qquad \forall x\in C.$$
Denote by $d_\ell$ the distance function induced by these lengths.

Q1: What is the growth of the largest possible diameter $D(N)$ for such $(C,d_\ell)$?

I think I can prove a bound $D(N) \lesssim log(N)$, but I wonder if a constant bound could be true.
In fact, this is not the real question I have, but it seemed a reasonable way to get to it. The real question is about functions $f:C\to \mathbb{R}$ such that
$$(1) \qquad \sum_\epsilon \lvert f(x+\epsilon) - f(x) \rvert \le 1 \qquad \forall x\in C$$
and of vanishing average.

Q2: What is the largest possible value $\lVert f\rVert_\infty$ for such a function?

(My motivation is a toy example to test some concentration inequalities for Markov chains. In some cases I figured the semi-norm $\max_x \sum_\epsilon \lvert f(x+\epsilon)-f(x)\rvert$ should be efficient for the Glauber dynamic (aka lazy random walk) on $C$, but I need the above to get a good spectral gap in the corresponding functional space)

REPLY [4 votes]: This was too long for a comment, Fedor Petrov gave a very nice answer with sharp constant (see also fedja's comment with a finite constant), and I just want to give the  reference where the problem was solved back in 2000, for $f$ taking values in an arbitrary normed linear space $B$. 
The OP is asking a particular case of what is now called Pisier's inequality for $p=\infty$ without $\log(n)$ factor. 
Let $f:\{-1,1\}^{n} \to B,$ where $B$ is linear normed space. Define 
$$
D_{j}f(x) = \frac{f(x)-f(x^{j})}{2},
$$ 
where $x^{j}=(x_{1}, \ldots, -x_{j}, \ldots, x_{n})$, i.e., it puts negative sign in front of $j$-th coordinate. Then Pisier proved  

Theorem (Pisier, 1986). For all $1\leq p \leq \infty$, and any $f:\{-1,1\}^{n} \to B$ we have
  $$ (\mathbb{E}\|f-\mathbb{E}f\|^{p})^{1p} \leq C
 \log(n)\left(\mathbb{E}_{x} \mathbb{E}_{y}\|\sum_{j=1}^{n}
 y_{j}D_{j}f(x) \|^{p}\right)^{1/p}. $$

Later Talagrand (1993) showed that in general for $p<\infty$,  $\log(n)$ factor is sharp. However in case of $B=\mathbb{R}$, $\log(n)$ factor can be removed but with $C=C(p)$ (again $p<\infty$), and for the real-valued functions, the inequality is sometimes called Poincar\'e inequality, because the right hand side (by Khinchin's inequality) can be replaced by a more familiar discrete gradient:
$$
\|\nabla f\|_{p}:= \left(\mathbb{E}\left(\sum_{j=1}^{n} |D_{j}f|^{2}\right)^{p/2}\right)^{1/p}
$$
Finally, Wagner (2000) closed the gap by showing 

Theorem (Wagner, 2000). For $p=\infty$ Pisier's inequality holds without $\log(n)$ factor.

This answers OP,   because for $B=\mathbb{R}$,  Pisier's inequality  becomes  (without $\log(n)$ factor)
$$
\|f-Ef\|_{\infty} \leq C \| \sum_{j=1}^{n}|D_{j}f| \|_{\infty}.
$$
Pisier, Gilles, Probabilistic methods in the geometry of Banach spaces, Probability and analysis, Lect. Sess. C.I.M.E., Varenna/Italy 1985, Lect. Notes Math. 1206, 167-241 (1986). ZBL0606.60008.
Wagner, R., Notes on an inequality by Pisier for functions on the discrete cube, Milman, V. D. (ed.) et al., Geometric aspects of functional analysis. Proceedings of the Israel seminar (GAFA) 1996-2000. Berlin: Springer. Lect. Notes Math. 1745, 263-268 (2000). ZBL0981.46021.
Talagrand, M., Isoperimetry, logarithmic Sobolev inequalities on the discrete cube, and Margulis’ graph connectivity theorem, Geom. Funct. Anal. 3, No. 3, 295-314 (1993). ZBL0806.46035.