Exemplo n.º 1
0
    def test_katie_graph(self):
        '''Test an LD graph from Katie that seems to be probelmatic.'''
        g = nx.Graph()
        g.add_nodes_from(['70', '60', '75', '67', '77', '63', '76', '89', '37'])
        g.add_edges_from([('70', '63'), ('70', '60'), ('70', '75'), ('70', '67'), ('70', '77'), ('70', '76'), ('70', '89'), ('70', '37'), ('60', '89'), ('60', '75'), ('60', '67'), ('60', '76'), ('60', '63'), ('75', '67'), ('75', '77'), ('75', '76'), ('75', '89'), ('75', '63'), ('75', '37'), ('67', '77'), ('67', '76'), ('67', '89'), ('67', '63'), ('67', '37'), ('77', '89'), ('77', '76'), ('77', '63'), ('77', '37'), ('63', '76'), ('63', '89'), ('63', '37'), ('76', '89'), ('76', '37')])
        position = dict([('37', 37441365), ('60', 37441980), ('63', 37482151), ('67', 37487632), ('70', 37487723), ('75', 37487866), ('76', 37487873), ('77', 37487975), ('89', 37488499)])

        expected_colors = [0, 0, 1, 2, 3, 4, 5, 6, 7]
        c = ld_graph.greedy_coloring(g, position)
        assert_equal(list(bad_edges(g, c)), [], 'Edges found within a frame')
        assert_equal(map(c.get, sorted(c)), expected_colors, 'Wrong greedy coloring')
Exemplo n.º 2
0
    def test_katie_graph(self):
        '''Test an LD graph from Katie that seems to be probelmatic.'''
        g = nx.Graph()
        g.add_nodes_from(
            ['70', '60', '75', '67', '77', '63', '76', '89', '37'])
        g.add_edges_from(
            [('70', '63'), ('70', '60'), ('70', '75'), ('70', '67'),
             ('70', '77'), ('70', '76'), ('70', '89'), ('70', '37'),
             ('60', '89'), ('60', '75'), ('60', '67'), ('60', '76'),
             ('60', '63'), ('75', '67'), ('75', '77'), ('75', '76'),
             ('75', '89'), ('75', '63'), ('75', '37'), ('67', '77'),
             ('67', '76'), ('67', '89'), ('67', '63'), ('67', '37'),
             ('77', '89'), ('77', '76'), ('77', '63'), ('77', '37'),
             ('63', '76'), ('63', '89'), ('63', '37'), ('76', '89'),
             ('76', '37')])
        position = dict([('37', 37441365), ('60', 37441980), ('63', 37482151),
                         ('67', 37487632), ('70', 37487723), ('75', 37487866),
                         ('76', 37487873), ('77', 37487975), ('89', 37488499)])

        expected_colors = [0, 0, 1, 2, 3, 4, 5, 6, 7]
        c = ld_graph.greedy_coloring(g, position)
        assert_equal(list(bad_edges(g, c)), [], 'Edges found within a frame')
        assert_equal(map(c.get, sorted(c)), expected_colors,
                     'Wrong greedy coloring')
Exemplo n.º 3
0
 def __test_greedy_coloring(self, g, position, expected_colors):
     '''Test the greedy coloring algorithm.'''
     c = ld_graph.greedy_coloring(g, dict(zip(g.nodes(), position)))
     assert_equal(list(bad_edges(g, c)), [], 'Edges found within a frame')
     assert_equal(
         map(c.get, sorted(c)), expected_colors, 'Wrong greedy coloring')
Exemplo n.º 4
0
 def __test_greedy_coloring(self, g, position, expected_colors):
     '''Test the greedy coloring algorithm.'''
     c = ld_graph.greedy_coloring(g, dict(zip(g.nodes(), position)))
     assert_equal(list(bad_edges(g, c)), [], 'Edges found within a frame')
     assert_equal(map(c.get, sorted(c)), expected_colors,
                  'Wrong greedy coloring')