fiji / SNT

Legacy project superseded by https://github.com/morphonets/SNT
GNU General Public License v3.0
11 stars 29 forks source link

Add a fix for the termination condition of GraphUtils.firstRelevantAncestor() #68

Closed carshadi closed 4 years ago

carshadi commented 4 years ago

This PR proposes a fix regarding an oversight (on my part) for the termination condition of GraphUtils.firstRelevantAncestor(). The original termination condition fails if the root node of the graph happens to be a branch point of degree == 2. Here is a demonstration of the issue. The following hypothetical tree has the root node at the top with two children. bugdemo1 Running GraphUtils.getSimplifiedGraph() on this tree will result in the following when shown in the Dendrogram viewer: bugdemo2 Note how the root node is not connected to it's children (also note the node with ID 1 is obscured beneath the node with ID 2). The proposed fix modifies the GraphUtils.firstRelevantAncestor() function to terminate at either the root node (in-degree == 0) or any arbitrary branch point (out-degree > 1). Here is the result of the proposed fix: bugdemo3 The graph now has the correct connectivity and topology.