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()


data = None
data = ExportData()
data.load_file('../' + WORLD_TRADE_FLOW_DATA_FILE_ORIGINAL, should_read_world_datapoints=True)

#generate_matlab_histogram_code(data, [99], [2000], ['Georgia', 'USA'])
print_histogram_as_text(data, range(1963, 2001), data.countries())
#print_graph_densities_for_different_thresholds(data, thresholds, a_few_years)
print_missing_links_db(data, 2000, 90, 'def_d_histogram_pair_wise')
print_missing_links_db(data, 2000, 99, 'def_d_histogram_pair_wise')


from itertools import combinations
from project.config import WORLD_TRADE_FLOW_DATA_FILE_ORIGINAL
from project.export_data.exportdata import ExportData
from project.signed_networks.definitions import definition_C3, args_for_definition_C

data = ExportData()
data.load_file('../../' + WORLD_TRADE_FLOW_DATA_FILE_ORIGINAL, should_read_world_datapoints=True)

year = 1975
definition = definition_C3
args = args_for_definition_C(10, 5000)

for (A, B) in combinations(data.countries(), 2):
    print "%s,%s,%s" % (A, B, definition(data, year, A, B, args))