Skip to content

Commit a32fa69

Browse files
Leave some comments to discuss tomorrow if the subject arrives at it
1 parent 77389c2 commit a32fa69

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

alpha/alpha-algo/src/main/java/org/neo4j/gds/impl/spanningtree/KSpanningTree.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,27 @@ private boolean moveMakesSense(double cost1, double cost2, DoubleUnaryOperator m
264264
}
265265

266266
private SpanningTree combineApproach(SpanningTree tree) {
267-
267+
/*
268+
* these are quick and fast techniques of returning a k-Tree without having to worry about not
269+
* ending up with a tree of k nodes *1, which was the main reason why the existing algorithm did not work.
270+
*
271+
* Teh first approach just cuts leaves from the final MST
272+
* The second approach grows the MST step-by-step and cuts leaves when it needs to trim an edge
273+
*
274+
* Neither of this approach is the best by itself (the approach of cutting arbitrary heavy nodes is also
275+
* plagued by a lot of mistakes)
276+
* but it is not hard to construct situations where one works well and the other does not.
277+
* So I thought of combining the two get the best.
278+
*
279+
* I think we can have this ready for a 2.3.1 patch-release (let's not rush it for thursday; it's alpha after all)
280+
* and for 2.4 we can try do write some more sophisticated methods (to get the optimal answer for a given
281+
* tree you need O(nk^2) time i think so it's maybe not doable*2)
282+
*
283+
* *1: we can modify the LinkCutTree so that we can check size of resulting sub trees after a cut, but for that
284+
* need to relearn the code :)
285+
* *2: and that is not guaranteed to be the optimal answer in general just for that particular tree :)
286+
*
287+
*/
268288
var spanningTree1 = cutLeafApproach(tree); //should clone 'tree'
269289
var spanningTree2 = growApproach(tree);
270290

0 commit comments

Comments
 (0)