From d478ccd9552e0bbe0773d54b7dcbb12e008fef40 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Sun, 17 May 2020 17:53:01 +0200 Subject: [PATCH] documentation --- README.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 667e0fc..106d4a5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # @sapphirecode/graphviz-builder -version: 0.0.0 +version: 1.1.x constructing graphviz files using an easy typescript interface @@ -12,11 +12,39 @@ npm: yarn: -> yarn add @sapphirecode/graphviz-builder +> yarn add @sapphirecode/graphviz-builder ## Usage -TODO: Add usage +### Object structure + +```js +import {Graph,Color} from '@sapphirecode/graphviz-builder'; + +// create a new graph +const g = new Graph('foo'); + +// add a node to the graph +// this function returns the full name of the node that's later used for creating edges +const bar = g.add_node('bar'); + +// if you want to specify attributes +const baz = g.add_node(n => { + n.name = 'baz'; + n.label = 'node baz'; + n.color = Color.red; +}); + +// connect nodes +g.add_edge(bar, baz); + +// add a subgraph +g.add_graph(sg=>{ + sg.name = 'subgraph'; + + sg.add_node('foo'); +}) +``` ## License