Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
/ bs-dagre Public archive

A BuckleScript interface for dagre, a directed graph layout for JavaScript

License

Notifications You must be signed in to change notification settings

arnau/bs-dagre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-dagre

BuckleScript bindings for dagre.

Status

  • Bindings for graphlib public interface.
  • Bindings for dagre public interface.

Naming and organisation

Although most names come straight from the original library, there are a few changes to adapt to Reason and a few aliases for my own benefit.

  • Bindings for graphlib ara under the Dagre.Graph module.
  • Bindings for dagre are under the Dagre.Layout module.
  • graphlib uses "label" to refer to data associated with graph, nodes and edges. bs-dagre uses "attributes" instead. For example, instead of setDefaultNodeLabel you have setDefaultNodeAttrs.

Usage

The steps to compute a graph layout are: create a graph, add nodes and edges and finally create a layout.

Crate a graph

open Dagre;

let graph = Graph.make();
Graph.setDefaultEdgeAttrs(graph, () => {"minlen": 2});

The snippet above creates a graph with default attributes, if you need to tweak them, use Graph.Attrs.make.

Add nodes and edges

Graph.setNodeWith(graph, "a", Node.attrs(~label="first", ~width=20, ~height=20), ());
Graph.setNodeWith(graph, "b", Node.attrs(~label="second", ~width=20, ~height=20), ());

Graph.setEdge(graph, Edge.t(~v="a", ~w="b", ()));

Create a layout

let layout = Layout.make(graph);

// Use the layout to render the graph.

Check the examples for more.

License

bs-dagre is licensed under the terms of the MIT License. See the LICENSE file for details.

About

A BuckleScript interface for dagre, a directed graph layout for JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages