def test_diamond(self): '''Simple diamond graph w/two equal paths.''' g = nx.Graph() g.add_path(['A', 'B', 'Z', 'C', 'A']) set_unit_weights(g) paths = edge_disjoint_shortest_pair(g, 'A', 'Z') exp_paths = [['A', 'B', 'Z'], ['A', 'C', 'Z']] compare_path_lists(self, paths, exp_paths)
def test_example_3_13_a_mod_2(self): '''Example 3.13a on pg 65, mod on pg 78. This example has two equally good path choices, so only check sum of paths. ''' g = graph_fig_3_13_a_mod_2 ed_paths = edge_disjoint_shortest_pair(g, 'A', 'Z') ed_paths_len = sum([pathlen(g, ed_paths[i]) for i in [0, 1]]) exp_paths = [[i for i in 'ABCDEFZ'], [i for i in 'AGDHZ']] exp_paths_len = sum([pathlen(g, exp_paths[i]) for i in [0, 1]]) self.assertEqual(ed_paths_len, exp_paths_len)
def test_example_3_14(self): '''Example 3.14 on pg 76.''' g = graph_fig_3_14 ed_paths = edge_disjoint_shortest_pair(g, 'A', 'Z') exp_paths = [[i for i in 'ABCDZ'], [i for i in 'AEDFZ']] compare_path_lists(self, ed_paths, exp_paths, g, 12)
def test_example_3_13_a(self): '''Example 3.13a on pg 65.''' g = graph_fig_3_13_a paths = edge_disjoint_shortest_pair(g, 'A', 'Z') exp_paths = [[i for i in 'AGCDEFZ'], [i for i in 'ABIZ']] compare_path_lists(self, paths, exp_paths)