https://github.com/mashingan/graflib
Very simple graph implementation library.
https://github.com/mashingan/graflib
graph-algorithms nim
Last synced: 10 months ago
JSON representation
Very simple graph implementation library.
- Host: GitHub
- URL: https://github.com/mashingan/graflib
- Owner: mashingan
- License: mit
- Created: 2017-01-06T18:09:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T23:03:15.000Z (about 3 years ago)
- Last Synced: 2025-05-06T20:35:39.578Z (about 1 year ago)
- Topics: graph-algorithms, nim
- Language: Nim
- Homepage:
- Size: 500 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Graflib
This is minimal implementation of graph library. Using generic for labelling
and for adding a weight type.
Hopefully this can be expanded to more generic graph implementation.
The current implementation is able to
1. Make graph undirected.
2. Find nodes' neighbours within defined mapping.
3. Find the paths between origin node to destination node using DFS.
4. Find the shortest path between origin node to destination node using `A*`.
Available examples are provided in folder [examples](./examples).
## Note for A* searching
User must provide the proc that has signature
`proc cost[N, C](n1, n2: N): C` and `proc distance[N, C](n1, n2: N): C`
with `N` is the node type and `C` is the cost type.
The cost type has to support `<` and `+` operator to make `A*` search to work.
See the [tests/test_astar.nim](tests/test_astar.nim) for the example
to see how it works.
## Installation
```
$ nimble install https://github.com/mashingan/graflib
```
Minimum supported Nim version `1.2.0` in order to run the test.
## doc
[Documentation](https://mashingan.github.io/graflib/htmldocs/graflib.html)
### License
MIT