Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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)

Awesome Lists containing this project

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