Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 908 Bytes

README.md

File metadata and controls

39 lines (33 loc) · 908 Bytes

egraph

Layered graph layout tools

Quick Start

Developing a graph

var Graph = require('egraph/graph');

var graph = new Graph();
var u = 0;
var v = 1;
graph.addVertex(u, {label: 'Vertex 1', width: 5, height: 5});
graph.addVertex(v, {label: 'Vertex 2', width: 5, height: 5});
graph.addEdge(u, v, {weight: 1});

Laying out a graph

var Layouter = require('egraph/layouter/sugiyama');
var layouter = new Layouter()
  .vertexWidth((arg) => arg.d.width)
  .vertexHeight((arg) => arg.d.height);
var layout = layouter.layout(graph);
//> {
//>   vertices: {
//>     '0': { x: 2.5, y: 2.5, width: 5, height: 5, layer: 0, order: 0 },
//>     '1': { x: 17.5, y: 2.5, width: 5, height: 5, layer: 1, order: 0 }
//>   },
//>   edges: {
//>     '0': {
//>       '1': { points: [ [ 5, 2.5 ], [ 15, 2.5 ] ], reversed: false, width: 1 }
//>     },
//>     '1': {}
//>   }
//> }