Hi all , I had this problem of creating a supertree by recursive Alfred Aho's algorithm. So I divided the problem into its the key concepts and dealt with them one by one. I'll first put up my code I built with help of people on this forum and then later on I'll explain my problem.So here's what I've build till now

So this is what I have written till now. Now let me explain my problem.

Code

___INPUT(set of triplets)____ b c a a c d d e b

Set of species/vertices=a,b,c,d,e Now build the auxiliary graph by selecting first two vertices of each of the triplets,i.e.

Code

b c a c d e

The auxiliary graph thus generated will be

Code

a-c-b d-e

The number of connected components in this auxiliary graph (q)=2 (viz. a-c-b and d-e) The algorithm I need to implement is this:-

Code

TreeConstruct(S) 1. Let L be the set of species appear in S. Build G(L) 2. Let C1 , C2 , . . . , Cq be the set of connected components in G(L) 3. If q >1, then • For i = 1, 2, . . . , q, let Si be the set of triplets in S labeled by the set of leaves in Ci . • Let Ti = TreeConstruct(Si ) • Let T be a tree formed by connecting all Ti with the same parent node. Return T. 4. If q=1 and C1 contains exactly one leaf, return the leaf; else return fail.

The progression will be like this:-

Code

1. Initially we have q=2 (a-c-b & d-e). So introduce an internal vertex (u) and make these connected components child of u. u=> a-c-b; d-e; 2. Select component 1 = a-c-b. Check all lines from INPUT which are a subset of this component1.First line of INPUT i.e. "b c a" is a subset of component1. 3."b c a" now becomes the INPUT for the program and it is recursed again with this INPUT(Now for input "b c a" the auxiliary graph will be "b-c" & "a",i.e. two connected components,thus q=2 ...)

Final output(SUPERTREE) for the given input should be like this

Code

u => u => d => e => u => a => u => b => c

TRIPLETS(input) and SUPERTREE(output) look like these http://ars.sciencedirect.com/content/image/1-s2.0-S0166218X10000983-gr1.jpg

The picture link above has the exact triplets for my problem and the exact supertree(output) expected