An open API service indexing awesome lists of open source software.

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.

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