I'm currently working on the Travelling Salesman's Problem in a computer science module. I have implemented some linear programming techniques using the software lp_solve. I've ended up with an upper triangular matrix, that is missing the diagonal, consisting of $1$s and $0$s which indicate whether the route between two specific towns took place. Here's an example of what I'm talking about with 5 towns: $$\begin{bmatrix}\cdot & 0&0&0&1\\\cdot&\cdot & 0&0&1\\\cdot&\cdot&\cdot&0&1\\\cdot&\cdot&\cdot&\cdot&1\\\cdot&\cdot&\cdot&\cdot&\cdot\end{bmatrix}$$ I wanted to derive a formula that maps the position "single dimensional coordinate" to its corresponding matrix position vector. An example for clarity, again in a system of 5 towns: $$0\mapsto(0,1) \\ 1\mapsto(0,2) \\ 2\mapsto(0,3) \\ 3\mapsto(0,4) \\ 4\mapsto(1,2) \\ 5\mapsto(1,3) \\ 6\mapsto(1,4)\\ 7\mapsto(2,3)\\ 8\mapsto(2,4)\\ 9\mapsto(3,4)$$ where the "single-dimensional coordinate" I mentioned above is the index that gets mapped to the position vector.
So my question: how can I derive a formula that defines the map I've expressed above?
Check out the formulas given in this equivalent StackOverflow question.
https://stackoverflow.com/questions/27086195/linear-index-upper-triangular-matrix