Let $n>1$ be an integer. Given a simple graph $G$ on $n$ vertices $v_1, v_2, \dots, v_n$ we let $k(G)$ be the minimal value of $k$ for which there exist $n$ $k$-dimensional rectangular boxes $R_1, R_2, \dots, R_n$ in a $k$-dimensional coordinate system with edges parallel to the axes, so that for each $1\leq i<j\leq n$, $R_i$ and $R_j$ intersect if and only if there is an edge between $v_i$ and $v_j$ in $G$.

Define $M$ to be the maximal value of $k(G)$ over all graphs on $n$ vertices. Calculate $M$ as a function of $n$.