Ejemplo n.º 1
0
def filehandler():
    for filename in os.listdir('Data/INFECTIOUS_raw'):
        if 'listcontacts_2009_0' in filename:
            path = 'Data/INFECTIOUS_raw/' + filename
            graph = read_data(
                path
            )  # graph is a dynetx data structure for the temporal graph
            output_filename = 'Data/Preprocessed/preprocessed_' + filename[
                18:23]
            dn.write_snapshots(graph, output_filename)
            print('finished preprocessing day ', filename[18:23])
    print('finished preprocessing files')
Ejemplo n.º 2
0
 def test_snapshot_graph_flag(self):
     g = dn.DynGraph()
     g.add_interaction(1, 2, 2)
     g.add_interaction(1, 2, 2, e=6)
     g.add_interaction(1, 2, 7, e=11)
     g.add_interaction(1, 2, 8, e=15)
     g.add_interaction(1, 2, 18)
     g.add_interaction(1, 2, 19)
     dn.write_snapshots(g, "test4.txt", delimiter=" ")
     h = dn.read_snapshots("test4.txt", nodetype=int, timestamptype=int, keys=True)
     # self.assertEqual(list(g.stream_interactions()), list(h.stream_interactions()))
     self.assertEqual(g.number_of_interactions(), h.number_of_interactions())
     os.remove("test4.txt")