I’m trying to implement a Neighbor Joining algorithm, at the moment I have got it working as it should, calculating the correct lengths at each step and outputting the correct values.
However, I am struggling with obtaining the final output of the algorithm, I need it to output the overall calculated matrix representation because I would like to represent it visually as a graph. Through each iteration of the main loop of the algorithm I get a sub group of nodes that goes back into the start of the algorithm, but I don’t believe that this subgroup could be used because it contains redundant information that I can’t really specify whether or not will be needed in the final representation.
I am using this algorithm here: http://en.wikipedia.org/wiki/Neighbor_joining#The_algorithm
Any help would be fantastic and I can provide more information if needed, thanks.
I have read the link you provided and it seems to me that you do need the information.
Each step of the algorithm merges 2 nodes into 1, making your distance matrix smaller until everything is merged. You need to remember the distances of the nodes you merge to their resulting node. If you merge A and B, then the columns/rows of your distance matrix are replaced by a column/row belonging to a new node, u. You need to remember the distances of A and B to u.
After everything is merged, you should have all distances of all nodes that have to be connected and you can start visualizing.