Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dpapathanasiou/simple-graph-go
This is the Go implementation of simple-graph (https://github.com/dpapathanasiou/simple-graph)
https://github.com/dpapathanasiou/simple-graph-go
Last synced: 2 months ago
JSON representation
This is the Go implementation of simple-graph (https://github.com/dpapathanasiou/simple-graph)
- Host: GitHub
- URL: https://github.com/dpapathanasiou/simple-graph-go
- Owner: dpapathanasiou
- License: mit
- Created: 2022-12-31T18:37:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-02T20:25:16.000Z (about 2 years ago)
- Last Synced: 2024-11-08T00:36:45.182Z (3 months ago)
- Language: Go
- Size: 15.6 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome - dpapathanasiou/simple-graph-go - 01 star:0.0k fork:0.0k This is the Go implementation of simple-graph (https://github.com/dpapathanasiou/simple-graph) (Go)
README
# About
This is the [Go](https://golang.org/) implementation of [simple-graph](https://github.com/dpapathanasiou/simple-graph).
# Usage
## Installation
* [SQLite](https://www.sqlite.org/), version 3.31.0 or higher; get the latest source or precompiled binaries from the [SQLite Download Page](https://www.sqlite.org/download.html)
* [Go](https://golang.org/doc/install)
* [go-sqlite3](https://github.com/mattn/go-sqlite3)
```sh
go get github.com/mattn/go-sqlite3
```
* [go-graphviz](https://github.com/goccy/go-graphviz) for visualizations
```sh
go get github.com/goccy/go-graphviz
```
* Optionally, or if the statements in the [originating sql folder (https://github.com/dpapathanasiou/simple-graph/tree/main/sql) change, run the [constants generation script](generate-constants.sh) to rebuild the `constants.go` file
```sh
./generate-constants.sh
```## Basic Functions
The [database package](simplegraph/database.go) provides convenience functions for [atomic transactions](https://en.wikipedia.org/wiki/Atomicity_(database_systems)) to add, delete, connect, and search for nodes.
There are also [visualization functions](simplegraph/visualizer.go) to convert search and traversal outputs into [dot format](https://graphviz.org/pdf/dotguide.pdf) for conversion images.
## Testing
There are [unit tests](simplegraph/database_test.go) in the `simplegraph` package covering each of the basic functions.
Make sure to use the `json1` tags when running them:
```sh
cd simplegraph
go test -tags json1
```If you have the correct version of SQLite installed, the tests should all pass:
```sh
PASS
ok github.com/dpapathanasiou/simple-graph/go/simplegraph 0.067s
```### TODO
- [ ] Marshall/unmarshal using [json](https://golang.org/pkg/encoding/json/) (or [gabs](https://github.com/Jeffail/gabs), etc.) for injecting "id" fields, and merging bodies in update and [upsert](https://en.wiktionary.org/wiki/upsert) instead of the full replacement that happens now