The collocation together with takes a nominal complement. That together-with phrase, together with {something} is adverbial, and therefore readily follows immediately after the verb; assuming that the "variable" in question has been mentioned in the preceding sentence, we could write:
To distinguish them, the node index is stored, together with that variable, in the list.
It seems the list was also previously mentioned, to judge from the definite article, though it would be better if the list hadn't been mentioned until this sentence:
To distinguish them, the node index is stored, together with that variable, in a list.