G'MIC Challenge - Phylogeny Tree

Here’s something I always wanted to do:


But, I don’t know if I’m going to do the equal spacing thing.

That being said. Here’s a observation I have made. This is literally a binary tree. G’MIC has no native binary tree support though. So far, I have made this code which creates a full binary tree structure.

#@cli rep_binmapref: depth_level
#@cli : Create a image which can be used to create binary tree.
+rep_binmapref:
check isint($1,1,23)
bin_map_size={(1<<(1+$1))-1}
$bin_map_size,1,1,2
100%
f.. >"begin(
		list_of_step_size=vector(#w);
		list_of_step_size[0]=$1;
	);
	step_size=list_of_step_size[x];
	step_size?(
		list_of_step_size[x+(1<<step_size)]=list_of_step_size[x+1]=step_size-1;
		bin_branch=x+[1,1<<step_size];
		repeat(2,p,
			i[#-1,bin_branch[p]]=x;
		);
		bin_branch;
	):(
		[x,x];
	);
	"
a[-2,-1] c

Run

$ rep_binmapref 4

The first channel is left() index, and second channel is right() index, and third channel is previous() index. When i0 and i1 are the same, that’s a leaf.

The part of transversing a binary tree has been solved. However, I have not came up with a idea to make the phylolegy itself. Like, how to define the boundary? Would it be easier to transverse from bottom up (This can enable equal spacing)? And so on. I don’t really care about generating data to compute evolution phylogeny of an animal here. My goal is generate a random one.

1 Like

I use Mesquite for generating trees for lecture slides: https://www.mesquiteproject.org

Ok, after sketching out the problem, apparently I found another possible route, it doesn’t involve binary tree. You can create a list of available ints and position, and a way to exclude ranges. Then randomly connect as long as it would not skip over exclusion ranges. The part that’s not excluded in the exclusion range is in the middle. So, I will attempt this approach in the weekend. Binary tree is inherently top down, while this approach is bottom-up.