public static GetTestNetwork ( ) : TemporalNetwork | ||
return | TemporalNetwork |
public void GetUncorrelatedBetweennessPrefMatrixTest() { TemporalNetwork temp_net = ExampleData.GetTestNetwork(); Dictionary <string, int> index_pred = null; Dictionary <string, int> index_succ = null; double[,] actual = null; actual = BetweennessPref.GetUncorrelatedBetweennessPrefMatrix(temp_net, "e", out index_pred, out index_succ); Assert.IsNotNull(index_pred); Assert.IsNotNull(index_succ); Assert.IsNotNull(actual); // Check whether all entries in the normalized betweenness preference matrix returned match the expected values Assert.AreEqual(actual[index_pred["a"], index_succ["b"]], (2d / 11d) * (1d / 10d)); Assert.AreEqual(actual[index_pred["b"], index_succ["b"]], (1d / 11d) * (1d / 10d)); Assert.AreEqual(actual[index_pred["c"], index_succ["b"]], (6d / 11d) * (1d / 10d)); Assert.AreEqual(actual[index_pred["f"], index_succ["b"]], (1d / 11d) * (1d / 10d)); Assert.AreEqual(actual[index_pred["g"], index_succ["b"]], (1d / 11d) * (1d / 10d)); Assert.AreEqual(actual[index_pred["a"], index_succ["f"]], (2d / 11d) * (6d / 10d)); Assert.AreEqual(actual[index_pred["b"], index_succ["f"]], (1d / 11d) * (6d / 10d)); Assert.AreEqual(actual[index_pred["c"], index_succ["f"]], (6d / 11d) * (6d / 10d)); Assert.AreEqual(actual[index_pred["f"], index_succ["f"]], (1d / 11d) * (6d / 10d)); Assert.AreEqual(actual[index_pred["g"], index_succ["f"]], (1d / 11d) * (6d / 10d)); Assert.AreEqual(actual[index_pred["a"], index_succ["g"]], (2d / 11d) * (3d / 10d)); Assert.AreEqual(actual[index_pred["b"], index_succ["g"]], (1d / 11d) * (3d / 10d)); Assert.AreEqual(actual[index_pred["c"], index_succ["g"]], (6d / 11d) * (3d / 10d)); Assert.AreEqual(actual[index_pred["f"], index_succ["g"]], (1d / 11d) * (3d / 10d)); Assert.AreEqual(actual[index_pred["g"], index_succ["g"]], (1d / 11d) * (3d / 10d)); }
public void TimeReversalTest() { TemporalNetwork test = ExampleData.GetTestNetwork(); test.ReduceToTwoPaths(true); Assert.AreEqual(test.TwoPathCount, 10, "Number of paths in time-reversed temporal network is incorrect!"); }
public void LoadTemporalNetworkTest() { TemporalNetwork net = ExampleData.GetTestNetwork(); TemporalNetwork.SaveToFile("test.net", net); TemporalNetwork net2 = TemporalNetwork.ReadFromFile("test.net"); Assert.AreEqual(net, net2); }
public void GetBetweennessPrefMatrixTest() { TemporalNetwork temp_net = ExampleData.GetTestNetwork(); Dictionary <string, int> index_pred = null; Dictionary <string, int> index_succ = null; double[,] actual; actual = BetweennessPref.GetBetweennessPrefMatrix(temp_net, "e", out index_pred, out index_succ); Assert.IsNotNull(index_pred); Assert.IsNotNull(index_succ); Assert.IsNotNull(actual); // Check whether all entries in the normalized betweenness preference matrix returned match the expected values Assert.AreEqual(0d, actual[index_pred["a"], index_succ["b"]]); Assert.AreEqual(0d, actual[index_pred["b"], index_succ["b"]]); Assert.AreEqual(0d, actual[index_pred["c"], index_succ["b"]]); Assert.AreEqual(1d / 10d, actual[index_pred["f"], index_succ["b"]]); Assert.AreEqual(0d, actual[index_pred["g"], index_succ["b"]]); Assert.AreEqual(actual[index_pred["a"], index_succ["f"]], 0d); Assert.AreEqual(actual[index_pred["b"], index_succ["f"]], 0d); Assert.AreEqual(actual[index_pred["c"], index_succ["f"]], 11d / 20d); Assert.AreEqual(actual[index_pred["f"], index_succ["f"]], 0d); Assert.AreEqual(actual[index_pred["g"], index_succ["f"]], 1d / 20d); Assert.AreEqual(actual[index_pred["a"], index_succ["g"]], 2d / 10d); Assert.AreEqual(actual[index_pred["b"], index_succ["g"]], 1d / 10d); Assert.AreEqual(actual[index_pred["c"], index_succ["g"]], 0d); Assert.AreEqual(actual[index_pred["f"], index_succ["g"]], 0d); Assert.AreEqual(actual[index_pred["g"], index_succ["g"]], 0d); Assert.AreEqual(BetweennessPref.GetBetweennessPref(temp_net, "e"), 1.2954618442383219d); actual = BetweennessPref.GetBetweennessPrefMatrix(temp_net, "f", out index_pred, out index_succ); Assert.IsNotNull(index_pred); Assert.IsNotNull(index_succ); Assert.IsNotNull(actual); Assert.AreEqual(actual[index_pred["e"], index_succ["e"]], 1d); }
public void ReduceToTwoPathsTest() { TemporalNetwork test = ExampleData.GetTestNetwork(); test.ReduceToTwoPaths(); // There should be 12 two paths Assert.AreEqual(test.TwoPathCount, 12); // And 21 edges Assert.AreEqual(test.EdgeCount, 21); // The stripped network should contain 20 time steps Assert.AreEqual(test.Length, 20); Assert.AreEqual(test.MaxGranularity, 1); Assert.AreEqual(test.MinGranularity, 2); // The aggregate network should contain 8 weighted edges with a cumulative weight that matches 2 * twoPathCount Assert.AreEqual(test.AggregateNetwork.EdgeCount, 8); Assert.AreEqual(test.AggregateNetwork.CumulativeWeight, 22); // The second-order aggregate network should countain edges representing 6 different two-paths ... Assert.AreEqual(test.SecondOrderAggregateNetwork.EdgeCount, 6); // ... with a total weight of 11 Assert.AreEqual(test.SecondOrderAggregateNetwork.CumulativeWeight, 11); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(c;e)", "(e;f)")], 5.5d); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(g;e)", "(e;f)")], 0.5d); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(e;f)", "(f;e)")], 1d); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(f;e)", "(e;b)")], 1d); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(a;e)", "(e;g)")], 2d); Assert.AreEqual(test.SecondOrderAggregateNetwork[new Tuple <string, string>("(b;e)", "(e;g)")], 1d); // Check whether all the weights are correctly computed ... Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("e", "f")], 7, "The weight of egde (e,f) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("e", "b")], 1, "The weight of egde (e,b) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("b", "e")], 1, "The weight of egde (b,e) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("g", "e")], 1d / 2d, "The weight of egde (g,e) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("e", "g")], 3, "The weight of egde (e,g) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("f", "e")], 2, "The weight of egde (f,e) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("a", "e")], 2, "The weight of egde (a,e) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("c", "e")], 5 + 1d / 2d, "The weight of egde (c,e) in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork.MaxWeight, 7, "The maximum weight in the aggregate network is wrong!"); Assert.AreEqual(test.AggregateNetwork.MinWeight, 0.5d, "The minimum weight in the aggregate network is wrong!"); test = ExampleData.GetTestNetwork2(); test.ReduceToTwoPaths(); Assert.AreEqual(test.TwoPathCount, 7); Assert.AreEqual(test.Length, 3); Assert.AreEqual(test.MaxGranularity, 1); Assert.AreEqual(test.MinGranularity, 3); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("a", "b")], 1); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("b", "c")], 1d + 1d / 6d + 1d / 6d + 1d / 6d); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("d", "c")], 1d / 2d); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("c", "d")], 1d / 3d); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("c", "b")], 1d / 3d); Assert.AreEqual(test.AggregateNetwork[new Tuple <string, string>("c", "a")], 1d / 3d); }