def print_missing_links_db(data, year, T, log_file_name):
    two_way_args = args_for_definition_D(T)
    one_way_args = args_for_definition_D(T, mode='one-way')
    f = open(OUT_DIR.DEFINITION_D + log_file_name + ".%d.txt" % T, 'w')
    for (A, B) in countries.country_pairs(data.countries()):
        if definition_D(data, year, A, B, two_way_args) == NO_LINK:
            one_way = definition_D(data, year, A, B, one_way_args)
            other_way = definition_D(data, year, B, A, one_way_args)
            f.write("Y%d,%s,%s,%s,%s\n" % (year, file_safe(A), file_safe(B), one_way, other_way))
            if one_way != other_way:
                for Y in range(1963, 2001):
                    f.write("%d,%s,%s,%.4g,%.4g\n" % (
                        Y, file_safe(A), file_safe(B),
                        data.export_data_as_percentile(Y, A, B),
                        data.export_data_as_percentile(Y, B, A)))
    f.close()
def print_graph_densities_for_different_thresholds(data, thresholds, years):
    f = open(OUT_DIR.DEFINITION_D + 'combinations.txt', 'w')
    for T in thresholds:
        for year in years:
            positive_edges = 0
            negative_edges = 0
            for (A, B) in countries.country_pairs(data.countries()):
                link_sign = definition_D(data, year, A, B, args_for_definition_D(T, log_file=f))
                if link_sign == POSITIVE_LINK: positive_edges += 1
                if link_sign == NEGATIVE_LINK: negative_edges += 1
            N = 203
            density = 2.0 * (positive_edges + negative_edges) / (N * (N - 1)) * 100
            print "%d,%d,%f,%d,%d,%d" % (T, year, density, positive_edges, negative_edges, N)
    f.close()