def test_read_write_tm(self): tm = fnss.static_traffic_matrix(self.G, mean=10, stddev=0.1, max_u=0.9) tmp_tm_file = path.join(TMP_DIR, 'tms.xml') fnss.write_traffic_matrix(tm, tmp_tm_file) read_tm = fnss.read_traffic_matrix(tmp_tm_file) u, v = tm.od_pairs()[2] self.assertAlmostEqual(tm[(u, v)], read_tm[(u, v)])
def test_read_write_tms(self): tms = fnss.stationary_traffic_matrix(self.G, mean=10, stddev=0.1, gamma=1.2, log_psi=-0.3, n=5, max_u=0.9) tmp_tms_file = path.join(TMP_DIR, 'tms.xml') fnss.write_traffic_matrix(tms, tmp_tms_file) read_tms = fnss.read_traffic_matrix(tmp_tms_file) u, v = tms[3].od_pairs()[2] self.assertAlmostEqual(tms[3][(u, v)], read_tms[3][(u, v)])