Allow setNodes to take a function for the label argument