# Home

### @buggyorg/graphtools 0.4.0-pre.15

# Buggy graphtools

This package contains the graph API for Buggy graphs.

# Graph structure

A graph in Buggy is a directed, multigraph that allows compounds. Compounds are subgraphs in a node of the graph itself. You can picture it like this:

Each node in the graph also has to have at least one port. Ports are divided into input (green) and output ports (red). The format for a graph is JSON which contains five basic fields:

    {
      "nodes": [
        {"ref": "<meta-id>", "id": "<some-unique-id>"},
        {"id": "<u-id>", "version": "<semver-version>", "componentId": "<component-id>",
         "ports": [{"port": "<port-name>", "kind": "input|output", "type": "number"}],
         "atomic": "true", "metaInformation": {"some-key": "some-value"}},
        {"id": "<u-id>", "version": "<semver-version>", "atomic": false,
         "ports": [{"port": "<port-name>", "kind": "input|output", "type": "number"}],
         "nodes": <Sub-Nodes>, "edges": <Sub-Edges>, "metaInformation": {"some-key": "some-value"}},
      ],
      "edges": [
        {"from": "<node-id>:<port-name>", "to": "<node-id>:<port-name>", "layer": "dataflow"}
      ],
      "version": "<semver-version of graph API>",
      "components": [
        {"componentId": "<component-id>", "ports": [...], "atomic": true},
        {"componentId": "<component-id>", "ports": [...], "nodes": <Sub-Nodes>, "edges": <Sub-Edges>}
      ],
      "metaInformation": {"some-key": "some-value"}
    }

# Usage

    import * as Graph from '@buggorg/graphtools'

    Graph.nodes(graph)
    Graph.Node.id(graph)

You can find the JSDoc documentation here

## changeSet.js

This methods are for internal usage. They do not check for bad inputs and can create broken graphs. If you know what you are doing you can include them via `import * as ChangeSet from '@buggyorg/graphtools/changeSet'`.

Source:
  - changeSet.js, line 1

## graph/basic.js

Includes basic graph functions like creating a graph or cloning it.

Source:
  - graph/basic.js, line 1

## graph/internal.js

This methods are for internal usage. They do not check for bad inputs and can create broken graphs. If you know what you are doing you can include them via `import * as GraphInternals from '@buggyorg/graphtools/graph/internal'`.

Source:
  - graph/internal.js, line 1