how can one map barycentric indices to a single integer?

e.g.

Edit: added correct image

[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/9e7TY.jpg