You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, we want to limit the size of our spanning tree result, as we are only interested in finding a smaller tree within the graph, and not one that necessarily spans across all nodes.
14
+
Sometimes, we might require a spanning tree(a tree where its nodes are connected with each via a single path) that does not necessarily span all nodes in the graph.
15
15
The K-Spanning tree heuristic algorithm returns a tree with `k` nodes and `k − 1` relationships.
16
-
Our heuristic processes the result found by the Prim algorithm for the Minimum Weight Spanning Tree problem.
16
+
Our heuristic processes the result found by Prim's algorithm for the xref:algorithms/minimum-weight-spanning-tree.adoc[Minimum Weight Spanning Tree] problem.
17
+
Like Prim, it starts from a given source node, finds a spanning tree for all nodes and then removes nodes using heuristics to produce a tree with 'k' nodes.
18
+
Note that the source node will not be necessarily included in the final output as the heuristic tries to find a globally good tree.
17
19
18
20
[[algorithms-k-spanning]]
19
21
== Considerations
20
-
The minimum weight k-Spanning Tree is NP-Hard. The algorithm in the Neo4j GDS Library is therefore not guaranteed to find the optimal answer, but should return good approximation in practice.
22
+
The Minimum weight k-Spanning Tree is NP-Hard. The algorithm in the Neo4j GDS Library is therefore not guaranteed to find the optimal answer, but should hopefully return a good approximation in practice.
23
+
24
+
Like Prim algorithm, the algorithm focuses only on the component of the source node. If that component has fewer than `k` nodes, it will not look into other components, but will instead return the component.
0 commit comments