I'm glad you asked this question. I tried to support reading and
writing GEXF format files with dynamics. Try reading the file from
http://gexf.net/data/dynamics.gexf
That shows how NetworkX stores the data internally as attributes.
e.g.
In [1]: import networkx as nx
In [2]: G=nx.read_gexf('dynamics.gexf')
In [3]: G.nodes(data=True)
Out[3]:
[('1',
{'indegree': [(1.0, None, '2009-03-01'),
(2.0, '2009-03-01', '2009-03-10'),
(1.0, '2009-03-10', None)],
'label': 'Network'}),
('0',
{'indegree': [(1.0, None, None)],
'label': 'Gephi',
'start': '2009-03-01',
'url': u'http://gephi.org'}),
('3',
{'frog': False,
'indegree': [(0.0, None, '2009-03-01'), (1.0, '2009-03-01', None)],
'label': 'Graph'}),
('2',
{'indegree': [(0.0, None, '2009-03-01'), (1.0, '2009-03-01', None)],
'label': 'Visualization',
'spells': [(None, '2009-03-01'), ('2009-03-05', '2009-03-10')]})]
In [4]: G.edges(data=True)
Out[4]:
[('1', '0', {'id': '2', 'start': '2009-03-01'}),
('0', '1', {'id': '0', 'start': '2009-03-01'}),
('0', '3', {'id': '4', 'start': '2009-03-01'}),
('0', '2', {'end': '2009-03-10', 'id': '1', 'start': '2009-03-01'}),
('2', '1', {'end': '2009-03-10', 'id': '3'})]
You can then write this graph
In [5]: nx.write_gexf(G,'test.gexf')
and (hopefully) Gephi can read it.
Is there a simpler or more natural way to store the time attributes
with NetworkX?
Aric
If you want to do it correctly (and it likely isn't completely correct
the way it is), read the spec page 15ff at
http://gexf.net/1.2draft/gexf-12draft-primer.pdf
Note that the NetworkX code tries to handle both the 1.1 spec and the
1.2draft spec which I think differ in the way they handle dynamic
data.
Aric
I think this is a bug that we fixed fairly recently to handle 1.2draft
spec files.
https://networkx.lanl.gov/trac/ticket/497
That fix was after the networkx-1.4 release so you will need to
install the development version.
You can get that from
http://networkx.lanl.gov/download/networkx/dev/
Aric