krashkov / SteinerNet

R Package: Steiner tree approach for graph analysis
https://github.com/krashkov/SteinerNet
8 stars 4 forks source link

Deletion of joint subtrees in steinertree3 incomplete #3

Open m-i-c-h-ael opened 1 year ago

m-i-c-h-ael commented 1 year ago

Hi, I believe there is an issue with the merging of non-disjoint subtrees in the steinertree3 function in steinertree.R (lines 261 and following): I encountered a case where there is no overlap between my trees with i=1 and j=2. So j is increased to 3. In this case there was an overlap between the i=1 and j=3 trees. When j reaches the end of the subtree list, i is increased. The problem is that the tree at i=1 is not the same anymore than the one that has been tested against j=2 (because it has been merged with other trees), so the new i=1 and j=2 trees may actually overlap. In my case, this lead to an empty list when calculating 'nsubtrees', which cased an error. A solution may be to not increase i in a loop where something has been merged into the corresponding tree. My code is too complex to share here, but I hope the explanation makes sense.