Skip to content

Commit c6d9980

Browse files
Proofreading
1 parent ff99dd4 commit c6d9980

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

doc/modules/ROOT/pages/alpha-algorithms/k-minimum-weight-spanning-tree.adoc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
= Minimum Weight k-Spanning Tree
44
:description: This section describes the Minimum Weight k-Spanning Tree algorithm in the Neo4j Graph Data Science library.
55
:entity: node
6-
:result: spanning tree edge
6+
:result: spanning tree
77
:algorithm: k-Spanning Tree heuristic
88

99
include::partial$/operations-reference/alpha-note.adoc[]
1010

1111

1212
== Introduction
1313

14-
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.
1515
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.
1719

1820
[[algorithms-k-spanning]]
1921
== 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.
25+
2126
[[algorithms-minimum-k-weight-spanning-tree-syntax]]
2227
== Syntax
2328

@@ -46,7 +51,7 @@ YIELD effectiveNodeCount: Integer,
4651
include::partial$/algorithms/common-configuration/common-parameters.adoc[]
4752

4853
.Configuration
49-
[opts="header",cols="1,1,1,1,4"]
54+
[opts="header",cols="3,2,3m,2,8"]
5055
|===
5156
| Name | Type | Default | Optional | Description
5257
include::partial$/algorithms/common-configuration/common-write-configuration-entries.adoc[]
@@ -72,7 +77,10 @@ include::partial$/algorithms/k-spanning-tree/specific-configuration.adoc[]
7277
[[algorithms-minimum-weight-spanning-tree-sample]]
7378
== Minimum Weight k-Spanning Tree algorithm examples
7479

75-
image::mst.png[]
80+
:algorithm-name: {algorithm}
81+
:graph-description: road network
82+
:image-file: spanning-tree-graph.svg
83+
include::partial$/algorithms/shared/examples-intro.adoc[]
7684

7785
.The following will create the sample graph depicted in the figure:
7886
[source, cypher, role=noplay setup-query]
@@ -113,8 +121,8 @@ CALL gds.graph.project(
113121

114122
=== Minimum K-Spanning Tree example
115123

116-
In our sample graph we have 5 nodes.
117-
By setting the `k=3`, we define that we want to get returned a 3-minimum spanning tree that covers 3 nodes and has 2 relationships.
124+
In our sample graph we have 7 nodes.
125+
By setting the `k=3`, we define that we want to find a 3-minimum spanning tree that covers 3 nodes and has 2 relationships.
118126

119127
.The following will run the k-minimum spanning tree algorithm and write back results:
120128
[role=query-example, no-result=true, group=write-example]
@@ -199,4 +207,4 @@ RETURN n.id As Place, p as Partition
199207
| "E" | 3
200208
|===
201209
--
202-
Nodes C, D, and E are the result 3-maximum spanning tree of our graph.
210+
Nodes C, D, and E form a 3-maximum spanning tree of our graph.

0 commit comments

Comments
 (0)