rsonthal/TreeRep

TreeRep.py also generates NJ output

Closed this issue · 8 comments

I tried executing TreeRep.py and got an adjacency matrix with twice the number of nodes, which is an attribute of neighbour join I think.
image

Yes, the matrix W will have double the size. But if you look at the matrix W, you might see that the a lot of the rows and columns are 0.

Basically, for speed, we pre-allocate the matrix W, which could be unto twice as big. However, we do not necessarily use all of those entries.

but that will create a problem I wanna reconstruct my original tree (wrt node labels, if node labels are meaningful).
I checked the paper which said it was the same size, so can I edit the code somewhere to get a matrix which is same sized. Or is there some other function for reconstruction of the tree.

In the pytorch wrapper file add the line

n = Main.eval('nv(G)')

And then modify the line

W = np.zeros_like(Main.dist)

To

W = np.zeros((n,n))

did that.
image
its still showing an extra node.

also, I was trying to figure this, but are the new nodes and old ones matched, as in, can I label the new adjacency matrix with old node labels?

The labels are matched! So if the old node was idx i, then the new node is still index i.

There will always be new nodes. The old ones are like the leave nodes and sometimes you need to add more nodes to build the tree.

Alright! so I can simply remove the last row and column and match the nodes to get final labelled results right?

Yes