Exemple #1
0
def main(source_path, destination_path, mat_type, tensor_dimension):
    for root, dirs, files in os.walk(source_path, topdown=False):
        for name in tqdm(files):
            adj = AdjacencyMatrix(source_path, destination_path, name.split('_')[0], mat_type, tensor_dimension)
            if mat_type == 'fully_connected':
                adj.fully_connected()
                adj.pad()
                adj.save_file()
            elif mat_type == 'direct_neighbour':
                adj.direct_neighbour()
                adj.save_file()
            elif mat_type == 'nearest_neighbour':
                adj.nearest_neighbour(radius)
                adj.save_file_nearest(radius)
Exemple #2
0
    vertex_visited[i] = True
    print(graph.get_vertex_value(i))

    for j in range(graph.get_number()):
        if graph.has_arc(i, j) and not vertex_visited[j]:
            depth_first_search(graph, j)


def depth_first_search_traverse(graph):
    global vertex_visited
    for i in range(graph.get_number()):
        if not vertex_visited[i]:
            depth_first_search(graph, i)


test = AdjacencyMatrix(False, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I')
test.insert_arc('A', 'B', 1)
test.insert_arc('A', 'F', 1)
test.insert_arc('B', 'G', 1)
test.insert_arc('F', 'G', 1)
test.insert_arc('E', 'F', 1)
test.insert_arc('E', 'H', 1)
test.insert_arc('D', 'E', 1)
test.insert_arc('D', 'H', 1)
test.insert_arc('G', 'H', 1)
test.insert_arc('D', 'G', 1)
test.insert_arc('D', 'I', 1)
test.insert_arc('C', 'D', 1)
test.insert_arc('C', 'I', 1)
test.insert_arc('B', 'C', 1)
test.insert_arc('B', 'I', 1)
Exemple #3
0
 def A(self):
     if self.adjacency_matrix is None:
         self.adjacency_matrix = self.__compute_adjacency_matrix__()
     return AdjacencyMatrix(self.adjacency_matrix, self.vertex_list)
Exemple #4
0
    1: cipher.func1,
    2: cipher.func2,
    3: cipher.func3,
    4: cipher.func4,
    5: cipher.make_gamma
}
lookup_table_modified = {
    1: cipher.func1_new,
    2: cipher.func2_new,
    3: cipher.func3,
    4: cipher.func4,
    5: cipher.make_gamma
}

print('Start original method')
adjacency_matrix = AdjacencyMatrix(init_state=init_state)
exec_flag = True
cur_state = init_state
while exec_flag:
    for cnt in range(len(seq_of_application_of_func)):
        cur_func = seq_of_application_of_func[cnt]
        new_state = lookup_table[cur_func](cur_state)

        if adjacency_matrix.edge_exist(cur_state, new_state, cur_func):
            exec_flag = False
            continue
        adjacency_matrix.add_edge(cur_state, new_state, cur_func)
        cur_state = new_state

print('save_matrix')
adjacency_matrix.save_matrix()