Example #1
0
def test_check_if_legal_vertex_cover():
    graph = graph_utils.graph_to_numpy(
        Graph(n=5, edges=[(1, 2), (3, 4), (4, 1)]))
    assert_equal(graph_utils.check_if_legal_vertex_cover(graph, ['v1', 'v3']),
                 True)
    assert_equal(graph_utils.check_if_legal_vertex_cover(graph, ['v1', 'v4']),
                 True)
    assert_equal(graph_utils.check_if_legal_vertex_cover(graph, ['v3', 'v4']),
                 False)
    assert_equal(graph_utils.check_if_legal_vertex_cover(graph, ['v1']), False)
    assert_equal(graph_utils.check_if_legal_vertex_cover(graph, ['v0']), False)
Example #2
0
 def test_algorithm(self):
     graph = Graph.Erdos_Renyi(10, 0.3)
     cover = most_neighbors_with_minimal_degree.most_neighbors_with_minimal_degree_algo(
         None, graph)
     assert_equal(
         graph_utils.check_if_legal_vertex_cover(
             graph_utils.graph_to_numpy(graph), cover), True)
def test_algorithm():
    graph = Graph.Erdos_Renyi(100, 0.05)
    cover = first_vertex_with_degree.first_vertex_with_degree_algo(None, graph)
    assert_equal(
        graph_utils.check_if_legal_vertex_cover(
            graph_utils.graph_to_numpy(graph), cover), True)
def test_algorithm():
    graph = Graph.Erdos_Renyi(100, 0.05)
    cover = neighbors_algo.neighbors_algo(None, graph)
    assert_equal(
        graph_utils.check_if_legal_vertex_cover(
            graph_utils.graph_to_numpy(graph), cover), True)
Example #5
0
 def test_random_graphs(self):
     for i in range(10):
         graph = graph_utils.random_graph(100, 0.1)
         g = graph_utils.graph_to_numpy(graph)
         cover = degree_minus(g)
         assert (graph_utils.check_if_legal_vertex_cover(g, cover))