コード例 #1
0
from hrw_hash_config import Ring
from util import get_entries_from_servers, write_output_to_file, write_entries_to_server
import sys, json
from server_config import server_list

if __name__ == '__main__':

    ring = Ring()
    ring.add(server_list[0])
    ring.add(server_list[1])
    ring.add(server_list[2])
    ring.add(server_list[3])

    write_entries_to_server(sys.argv[1], ring)

    print('Verifying the data...')

    data = get_entries_from_servers()

    print(json.dumps(data, indent=4))

    write_output_to_file('hrw_hash_output.json', data)

    print(
        'Data verification completed. Output written to "hrw_hash_output.json"'
    )
コード例 #2
0
ファイル: main.py プロジェクト: dseeto/mlst

    # get output
    output_edge_set = mlst_handler.find_mlst(edge_set)

    """
    draw the graph
    you need to install igraph and py-cairo module
    py-cairo can be installed by "sudo port install py-cairo"
    """
    #util.display(output_edge_set)
    return output_edge_set

if __name__ == "__main__":

    # create file objs from command line args
    args = get_args()

    # get input edges
    input_edge_sets = util.get_input_edge_sets(infile=args["input_filename"])

    output_edge_sets = []
    for edge_set in input_edge_sets:
        #output_edge_sets.append(find_mlst(edge_set=edge_set, MlstHandler=BruteforceMLST))
        output_edge_sets.append(find_mlst(edge_set=edge_set, MlstHandler=ConstantTimeMLST))

    # write output to file
    util.write_output_to_file(output_edge_sets,filename=args["output_filename"])


コード例 #3
0
ファイル: solver.py プロジェクト: dseeto/mlst
    """
    NOTE: Modify this list to add/remove/change generators
    """
    # graphs to generate
    nbit_generators = [
            NbitConstructor(max_nodes=100, degree=3),
            NbitConstructor(max_nodes=98, degree=33),
            NbitConstructor(max_nodes=10, degree=3),
            ]

    # -----------------------------------------------------------------------
    # write edge sets to file
    #edge_sets = map(generate_nbit_graph, nbit_generators)
    mlst_edge_sets = []
    orig_edge_sets = []

    for nbit_generator in nbit_generators:
        orig, mlst = generate_nbit_graph(nbit_generator)
        mlst_edge_sets.append(mlst)
        orig_edge_sets.append(orig)

    orig_filename = "hard.in"
    mlst_filename = "hard.out"
    util.write_output_to_file(orig_edge_sets, orig_filename)
    util.write_output_to_file(mlst_edge_sets, mlst_filename)

    print "Orig Edge Sets written to file '%s'" %(str(orig_filename))
    print "Mlst Edge Sets written to file '%s'" %(str(mlst_filename))


コード例 #4
0
ファイル: nbit.py プロジェクト: dseeto/mlst
    """
    NOTE: Modify this list to add/remove/change generators
    """
    # graphs to generate
    nbit_generators = [
            #NbitGenerator(max_nodes=100, degree=20),
            NbitGenerator(max_nodes=15, degree=3),
            ]

    # -----------------------------------------------------------------------
    # write edge sets to file
    #edge_sets = map(generate_nbit_graph, nbit_generators)
    edge_sets = []
    for nbit_generator in nbit_generators:
        eset, num_nodes, num_edges = generate_nbit_graph(nbit_generator)
        print "Graph Stats:"
        print "------------------------------------------------"
        print "Number of nodes: %d" %(num_nodes)
        print "Number of edges: %d" %(num_edges)
        print "%d node %d-bit Graph Generated" %(num_nodes, nbit_generator.degree)
        print "------------------------------------------------\n"
        edge_sets.append(eset)

    util.write_output_to_file(edge_sets, output_filename)
    print "Edge Sets written to file '%s'" %(str(output_filename))

    experiment()


コード例 #5
0
from consistent_hash_config import Ring
from util import get_entries_from_servers, write_output_to_file, write_entries_to_server
import sys, json
from server_config import server_list

if __name__ == '__main__':

    ring = Ring(server_list)

    write_entries_to_server(sys.argv[1], ring)

    print('Verifying the data...')

    data = get_entries_from_servers()

    print(json.dumps(data, indent=4))

    write_output_to_file('consistent_hash_output.json', data)

    print(
        'Data verification completed. Output written to "consistent_hash_output.json"'
    )