Say I have a tree that I'd like to visualize with d3. Nodes have various attributes produced by the d3 library, attributes like an index and position variables. Now, I could add more attributes to each node such as color, depth in the tree, or a label representing which disconnected graph contains the node. These attributes can all be represented with an integer attached to each node, or I could have a few arrays and make each attribute a reference to an array element. Which is better?
I'm sure the answer depends pretty strongly on the context, but it seems like we can split this into visualizations with a lot of nodes or visualizations with relatively few nodes. Keeping in mind the fact that a visualization may need to access or modify these attributes quite often, is this simply a trade-off between memory savings and array index operations? If I implement these two schemes in real code, how should I characterize the performance of each method?