Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
    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)
Exemple #4
0
    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)
Exemple #5
0
 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)
Exemple #6
0
 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)
Exemple #7
0
 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)
Exemple #8
0
 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)