You can add arbitrary node attributes, including functions, like this
In [1]: import networkx as nx
In [2]: G = nx.Graph()
In [3]: G.add_node(1,color='red')
In [4]: import math
In [5]: G.add_node('a',f = math.cos)
In [6]: G.node['a']['f'](math.pi)
Out[6]: -1.0