Commit cd98f001 authored by lykos98's avatar lykos98
Browse files

tested and plotted top tree

parent 030e7a87
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
main
sync.sh
bb
.ipy*

bb_plot.ipynb

0 → 100644
+205 −0

File added.

Preview size limit exceeded, changes collapsed.

+35 −1
Original line number Diff line number Diff line
@@ -734,6 +734,39 @@ void tree_print(global_context_t* ctx, top_kdtree_node_t* root)
	if(root -> lch) tree_print(ctx, root -> lch);
	if(root -> rch) tree_print(ctx, root -> rch);
}
void _recursive_nodes_to_file(global_context_t* ctx, FILE* nodes_file, top_kdtree_node_t* root, int level)
{
	fprintf(nodes_file, "%d,", level);
	fprintf(nodes_file, "%d,", root -> owner);
	fprintf(nodes_file, "%d,", root -> split_dim);
	fprintf(nodes_file, "%lf,", root -> split_val);
	for(int i = 0; i < ctx -> dims; ++i)
	{
		fprintf(nodes_file,"%lf,",root -> lb_node_box[i]);
	}
	for(int i = 0; i < ctx -> dims - 1; ++i)
	{
		fprintf(nodes_file,"%lf,",root -> ub_node_box[i]);
	}
	fprintf(nodes_file,"%lf\n",root -> ub_node_box[ctx -> dims - 1]);
	if(root -> lch) _recursive_nodes_to_file(ctx, nodes_file, root -> lch, level + 1);
	if(root -> rch) _recursive_nodes_to_file(ctx, nodes_file, root -> rch, level + 1);
}
void write_nodes_to_file( global_context_t* ctx,top_kdtree_t* tree, 
						const char* nodes_path) 
{
	FILE* nodes_file  = fopen(nodes_path,"w");

	if(!nodes_file) 
	{
		printf("Cannot open hp file\n");
		return;
	}
	_recursive_nodes_to_file(ctx, nodes_file, tree -> root, 0);
	fclose(nodes_file);

	
}

void tree_print_leaves(global_context_t* ctx, top_kdtree_node_t* root)
{
@@ -923,6 +956,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
	if(I_AM_MASTER)
	{
		tree_print(ctx, tree -> root);
		write_nodes_to_file(ctx, tree, "bb/nodes_50_blobs_more_var.csv");
	}

	
@@ -956,7 +990,7 @@ void simulate_master_read_and_scatter(int dims, size_t n, global_context_t *ctx)

	if (ctx->mpi_rank == 0) 
	{
		data = read_data_file(ctx, "../norm_data/blobs.npy", MY_TRUE);
		data = read_data_file(ctx, "../norm_data/50_blobs_more_var.npy", MY_TRUE);
		ctx->dims = 2;
		// std_g0163178_Me14_091_0000
		// data =