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
- Make graph undirected.
- Find nodes' neighbours within defined mapping.
- Find the paths between origin node to destination node using DFS.
- Find the shortest path between origin node to destination node using
A*.
Available examples are provided in folder examples.
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 for the example
to see how it works.
$ nimble install https://github.com/mashingan/graflib
Minimum supported Nim version 1.2.0 in order to run the test.
MIT