1.0.1 • Published 6 months ago

@graphty/layout v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Layout.js

Layout.js is a JavaScript library for node positioning in graphs. It is a JavaScript port of the layout algorithms found in the Python NetworkX library.

Features

The library offers various graph layout algorithms, including:

How to Use

Import the library into your JavaScript project:

import {
  randomLayout,
  circularLayout,
  springLayout
  // other layout functions...
} from './layout.js'

Usage example:

// Create a graph (data structure with nodes() and edges())
const graph = {
  nodes: () => [0, 1, 2, 3],
  edges: () => [
    [0, 1],
    [1, 2],
    [2, 3],
    [3, 0]
  ]
}

// Apply a layout
const positions = circularLayout(graph)

// positions will be an object with x,y coordinates for each node
// { 0: [1, 0], 1: [0, 1], 2: [-1, 0], 3: [0, -1] }

Requirements

  • Modern browser with ES6 support
1.0.1

6 months ago

1.0.0

6 months ago