Пример #1
0
def verify_uncoloring(str_graph_file, str_witness_file):
    G = gio.load_from_edge_list(str_graph_file)
    with open(str_witness_file, 'r') as f_uncol:
        lines = f_uncol.readlines()


    # verify line by line up to Q.E.D. is found
    for line in lines[8:-1]:
        word = line.split()
        if not verify_word(G, word): return False
Пример #2
0
def verify_coloring_dict(str_graph_file, W):
    G = gio.load_from_edge_list(str_graph_file)
    with open(str_witness_file, 'r') as f_col:
        lines = f_col.readlines()

    str_col = ''.join(l for l in lines[8, -1])
    C = eval(str_col)  # reads directly as a formated python str(dict())
    V = set()

    # 1st test: is there any edge in a purported independent set?
    for i in (1, 2, 3):
        for x, y in combinations(C[i], 2):
            if G.is_edge(x, y): return False, 'There is an edge' + str((x, y)) + ' in set ' + str(i) + '\n'
            V |= {x, y}

    # 2nd test: are all edges *** OF GRAPH G! *** included in C?
    if sorted(G.Vertices()) != sorted(V): return False, 'Not all vertices of G are included in the purported solution \n'


    return True