JSONL graph tools

Convenient to use with jq

Go Reference Go Report Card codecov Tests Awesome

$ go install github.com/nikolaydubina/[email protected]
# get https://graphviz.org/download/

Graph is represented as JSONL of nodes and edges.

Node contains id and any fields

{
    "id": "github.com/gin-gonic/gin",
    "can_get_git": true,
    "can_run_tests": true,
    "can_get_github": true,
    "github_url": "https://github.com/gin-gonic/gin",
    "git_url": "https://github.com/gin-gonic/gin",
    "git_last_commit": "2021-04-21",
    "git_last_commit_days_since": 4,
    "git_num_contributors": 321,
    ...
}

Edge contains from and to with node ids

{
    "from": "github.com/gin-gonic/gin",
    "to": "golang.org/x/tools"
}

Why?

JSONL is a perfect fit for storing graphs

  • can append new nodes and endges by concatenating files
  • nodes and edges can have any data
  • schemaless
  • any subset of lines is a valid graph

Examples

To illustrate, I am using data from import-graph. If you pass color scheme, then values will be colored.

colored.svg
“>

$ cat '
{"id":"github.com/gin-gonic/gin","can_get_git":true, ... }
{"id":"github.com/gin-contrib/sse","can_get_git":true,"can_run_tests":true ... }
...
{"from":"github.com/gin-gonic/gin","to":"golang.org/x/tools"}
{"from":"github.com/gin-gonic/gin","to":"github.com/go-playground/validator/v10"}
' | jsonl-graph -color-scheme=file://$PWD/docs/colors.json | dot -Tsvg > colored.svg

gin-color

By default, no coloring is applied.

basic.svg
“>

$ cat '
{"id":"github.com/gin-gonic/gin","can_get_git":true, ... }
{"id":"github.com/gin-contrib/sse","can_get_git":true,"can_run_tests":true ... }
...
{"from":"github.com/gin-gonic/gin","to":"golang.org/x/tools"}
{"from":"github.com/gin-gonic/gin","to":"github.com/go-playground/validator/v10"}
' | jsonl-graph | dot -Tsvg > basic.svg

gin-nocolor

If nodes have less fields, then adjusting graph

small.svg
“>

$ cat '
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"bufio"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"bytes"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"encoding/json"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"errors"}
{"from":"github.com/nikolaydubina/jsonl-graph/graph","to":"fmt"}
...
' | jsonl-graph | dot -Tsvg > small.svg

small

GitHub

https://github.com/nikolaydubina/jsonl-graph