Skip to content

Commit 1142822

Browse files
committed
rearanging example
1 parent 1acf46c commit 1142822

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

algorithms/mst.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parent: "Algorithms"
88

99
## Overview
1010

11-
The Minimum Spanning Tree (MST) identifies the minimum weight acyclic graph (tree) spanning every node in each weakly connected component in the graph, disregarding edge directions. Any nodes that shared a weakly connected component still share that component in the MST sub-graph.
11+
The Minimum Spanning Tree (MST) finds the relationships with minimum weights such that any weakly connected component in the graph stays connected. It treats all edges as bi-directional and ensures that any pair of nodes that previously shared a path will still share a unique path in the MST subgraph.
1212

1313
MST serves as a common algorithm in scenarios such as:
1414
- Designing a cost-effective road network connecting several cities.
@@ -19,7 +19,7 @@ MST serves as a common algorithm in scenarios such as:
1919

2020
MST first assigns each node to its own component. It iteratively scans for the minimum edges linking nodes across different components and merges them, ignoring the direction of edges throughout the process. The algorithm terminates when no further merges occur, producing a collection of trees.
2121

22-
The procedure finds a minimum or maximum weight spanning tree based on the specified attribute. If no attribute is given, returns any spanning tree. If any specified edges do not have the given weight attribute, or the value of the attribute is non-numeric, then they are treated as if they had infinite weight. Such an edge would only be included in the minimum spanning tree if no other edges with a valid weight attribute bridge the components it connects.
22+
The procedure finds a minimum or maximum weight spanning tree based on the specified `objective` and optimizes for the given `weightAttribute`. If no attribute is given, MST returns any collection of spanning trees. If any specified edges do not have the given weight attribute, or the value of the attribute is non-numeric, then they are treated as if they had infinite weight. Such an edge would only be included in the minimum spanning tree if no other edges with a valid weight attribute bridge the components it connects.
2323

2424
## Syntax
2525

@@ -29,7 +29,7 @@ CALL algo.mst([config])
2929

3030
### Parameters
3131

32-
The procedure accepts an optional configuration `Map` with the following parameters:
32+
The procedure accepts an optional configuration `Map` with the following optional parameters:
3333

3434
| Name | Type | Default | Description |
3535
|---------------------|--------|------------------------|----------------------------------------------------------------------------|
@@ -46,11 +46,6 @@ The procedure returns a stream of records with the following fields:
4646
| `edge` | Edge | An edge entity which is part of the MST graph |
4747
| `weight` | Double | The weight of the Edge |
4848

49-
## Examples:
50-
51-
Lets take this City as an example:
52-
53-
![City Graph](../images/city_plan.png)
5449

5550

5651

@@ -75,18 +70,22 @@ CREATE
7570
(CityHall)-[tA:TRAM {cost: 1.5}]->(Building_A),
7671
(CourtHouse)-[tB:TRAM {cost: 7.3}]->(Building_B),
7772
(FireStation)-[tC:TRAM {cost: 1.2}]->(Electricity)
73+
RETURN *
7874
```
79-
### Example: Find cheapest road network:
75+
76+
## Examples:
77+
78+
Suppose you are an urban planner tasked with designing a new transportation network for a town. There are several vital buildings that must be connected by this new network. A cost estimator has already provided you with the estimated cost for some of the potential routes between these buildings.
79+
80+
Your goal is to connect every major building with the lowest total cost, even if travel between some buildings requires multiple stops and different modes of transport. The Minimum Spanning Tree algorithm helps you achieve this by identifying the most cost-effective network.
81+
82+
![City Graph](../images/city_plan.png)
83+
8084
```cypher
8185
CALL algo.mst({weightAttribute: 'cost'}) YIELD edge, weight
8286
```
8387

8488
#### Expected Results
85-
| Edge | weight |
86-
|-----------|--------|
87-
| `[:ROAD]` | 0.7 |
88-
| `[:TRAM]` | 1.2 |
89-
| `[:TRAM]` | 1.5 |
90-
| `[:ROAD]` | 2.2 |
91-
| `[:ROAD]` | 2.3 |
92-
| `[:ROAD]` | 3.0 |
89+
The algorithm would yeild the following edge objects and their weights:
90+
91+
![City MST Graph](../images/city_mst.png)

images/city_mst.png

632 KB
Loading

images/city_plan.png

694 KB
Loading

0 commit comments

Comments
 (0)