def testSketchMatrix_ReadWrite(self):
     file_name = "test_files/sketch_matrix.tmp"
     dummy_hypergraph = Hypergraph(example_graphs.snm_dummy_graph)
     rballs_database, _ = similar_nodes_mining.extract_rballs_database(dummy_hypergraph, r_in=2, r_out=2, r_all=0)
     nodes_count = dummy_hypergraph.number_of_nodes()
     ch_matrix = CharacteristicMatrix(rballs_database, nodes_count, wl_iterations=4)
     sketch_matrix = SketchMatrix(5, 20, ch_matrix)
     sketch_matrix.save_to_file(file_name)
     read_sketch_matrix = SketchMatrix.load_from_file(file_name)
     equality = (read_sketch_matrix.matrix == sketch_matrix.matrix).all()
     self.assertTrue(equality, "The read sketch matrix is different from the saved one.")
 def testSketchMatrix_ReadWrite(self):
     file_name = "test_files/sketch_matrix.tmp"
     dummy_hypergraph = Hypergraph(example_graphs.snm_dummy_graph)
     rballs_database, _ = similar_nodes_mining.extract_rballs_database(
         dummy_hypergraph, r_in=2, r_out=2, r_all=0)
     nodes_count = dummy_hypergraph.number_of_nodes()
     ch_matrix = CharacteristicMatrix(rballs_database,
                                      nodes_count,
                                      wl_iterations=4)
     sketch_matrix = SketchMatrix(5, 20, ch_matrix)
     sketch_matrix.save_to_file(file_name)
     read_sketch_matrix = SketchMatrix.load_from_file(file_name)
     equality = (read_sketch_matrix.matrix == sketch_matrix.matrix).all()
     self.assertTrue(
         equality,
         "The read sketch matrix is different from the saved one.")
def load_sketch_matrix():
    print "Reading NodeID map started at", time.strftime(time_format)
    start = time.time()
    node_id_map = inout.load_from_file(path + "{0}_node_id_map".format(dataset))
    print "Reading NodeID map took", time.time() - start, "s"
    
    print "Reading sketch matrix started at", time.strftime(time_format)
    start = time.time()
    sketch_matrix = SketchMatrix.load_from_file(path + "{0}_sketch".format(dataset))
    print "Reading sketch matrix took", time.time() - start, "s"
    print "-----------------------------------------"
    
    print "Reading Column index to Node map started at", time.strftime(time_format)
    start = time.time()
    index_node_map = inout.load_from_file(path + "{0}_index_node_map".format(dataset))
    print "Reading Column index to Node map took", time.time() - start, "s"
    print "-----------------------------------------"
    
    return sketch_matrix, index_node_map, node_id_map
def load_sketch_matrix():
    print "Reading NodeID map started at", time.strftime(time_format)
    start = time.time()
    node_id_map = inout.load_from_file(path +
                                       "{0}_node_id_map".format(dataset))
    print "Reading NodeID map took", time.time() - start, "s"

    print "Reading sketch matrix started at", time.strftime(time_format)
    start = time.time()
    sketch_matrix = SketchMatrix.load_from_file(path +
                                                "{0}_sketch".format(dataset))
    print "Reading sketch matrix took", time.time() - start, "s"
    print "-----------------------------------------"

    print "Reading Column index to Node map started at", time.strftime(
        time_format)
    start = time.time()
    index_node_map = inout.load_from_file(path +
                                          "{0}_index_node_map".format(dataset))
    print "Reading Column index to Node map took", time.time() - start, "s"
    print "-----------------------------------------"

    return sketch_matrix, index_node_map, node_id_map