https://github.com/hexlet-components/js-graphs
https://github.com/hexlet-components/js-graphs
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hexlet-components/js-graphs
- Owner: hexlet-components
- Created: 2019-12-18T17:30:31.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-05T07:31:50.000Z (almost 2 years ago)
- Last Synced: 2025-10-28T00:32:32.366Z (8 months ago)
- Language: JavaScript
- Size: 4.66 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-graphs
[](https://github.com/hexlet-components/js-graphs/actions)
## Install
```sh
npm install @hexlet/graphs
```
## Usage example
```javascript
import {
makeJoints, buildTreeFromLeaf, sortTree,
} from '@hexlet/graphs';
const tree = ['B', [
['D'],
['A', [
['C', [
['F'],
['E'],
]],
]],
]];
const joints = makeJoints(tree);
const transformed = buildTreeFromLeaf(joints);
// ['C', [
// ['F'],
// ['E'],
// ['A', [
// ['B', [
// ['D'],
// ]],
// ]],
// ]];
sortTree(transformed);
// ['C', [
// ['A', [
// ['B', [
// ['D'],
// ]],
// ]],
// ['E'],
// ['F'],
// ]];
```
For more information, see the [Full Documentation](https://github.com/hexlet-components/js-graphs/tree/master/docs)
---
[](https://hexlet.io?utm_source=github&utm_medium=link&utm_campaign=js-graphs)
This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet](https://hexlet.io?utm_source=github&utm_medium=link&utm_campaign=js-graphs).
See most active contributors on [hexlet-friends](https://friends.hexlet.io/).