https://github.com/semibran/graph-mst
:chart_with_upwards_trend: minimum spanning tree generator
https://github.com/semibran/graph-mst
graph-theory minimum-spanning-tree
Last synced: 12 months ago
JSON representation
:chart_with_upwards_trend: minimum spanning tree generator
- Host: GitHub
- URL: https://github.com/semibran/graph-mst
- Owner: semibran
- License: mit
- Created: 2018-03-04T08:45:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-07T03:00:52.000Z (over 8 years ago)
- Last Synced: 2025-04-02T16:01:56.603Z (about 1 year ago)
- Topics: graph-theory, minimum-spanning-tree
- Language: JavaScript
- Homepage: https://semibran.github.io/graph-mst/
- Size: 319 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# graph-mst
> generates a minimum spanning tree from a weighted graph

This module exposes the `span` function, which uses [Prim's algorithm] to generate a [minimum spanning tree] from a weighted graph.
## usage
### `span(graph) -> tree`
Converts a `graph` with the fields `nodes : [ x, y ]` and `edges : { endpoints : [ ...nodeIndices ], weight: Number }` to a minimum spanning tree.
[Prim's algorithm]: https://en.wikipedia.org/wiki/Prim%27s_algorithm
[Minimum spanning tree]: https://en.wikipedia.org/wiki/Minimum_spanning_tree