New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ogdfjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ogdfjs

A JavaScript Graph Drawing Library Emscripts the C++ Library [OGDF](https://ogdf.uos.de/)

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

ogdf.js

A JavaScript Graph Drawing Library Emscripts the C++ Library OGDF.

Introduction

The project is forked from Basasuya/ogdf.js. The idea of this project is to compile the C++ library OGDF into a JavaScript library. The former stands both for Open Graph Drawing Framework (the original name) and Open Graph algorithms and Data structures Framework.

We now aim to use emscripten to compile the Layout part of OGDF into ogdf.js.

How to use

  • npm (ogdfjs):

    $ npm install ogdfjs
    
  • unpkg: ogdf.js

    <script src="https://unpkg.com/ogdfjs"></script>
    

Layout Supported

Some layout algorithms are supported now:

Energy-based Layout Algorithms
Layer-based Layout Algorithms
  • Sugiyama: Sugiyama's layout algorithm.
Planar and Planarization-based Layout Algorithms
Layout Algorithms for Clustered Graphs
  • ClusterOrtho: Represents a planar orthogonal drawing algorithm for c-planar, c-connected clustered graphs.

Examples can be found in ./examples. We use NetV.js to render the graph.

// layouts can be called like:
const Layout = ogdf.layouts.energebased.fm3
const fm3 = new Layout()
fm3.graph(/* graph data */ { nodes: facebook.nodes, links: facebook.links })
fm3.parameters(/* parameters */ { qualityVersusSpeed: "GorgeousAndEfficient" })
fm3.run().then(graph => {
    // ...
})

// or using import/export
import * as ogdf from 'ogdfjs'

How to build it?

We suggest you to build ogdf.js with Linux or MacOS (we still have no experience with Windows OS to build the ogdf library, for Windows developers, WSL is suggested). Before building the ogdf.js, you should make sure you have enviroments to build C++ library:

  • Git
  • CMake
  • Compiling tools. GCC (Linux), Xcode (MacOS)
  • Python 2.7.x

Building Steps

NOTE*: for Windows users, please use WSL to perform step 1~3.

  • Download and install Emscripten. Here is several main steps, and please refer to the official document for more details:

    # Get the emsdk repo
    $ cd ..
    $ git clone https://github.com/emscripten-core/emsdk.git
    
    # Enter that directory
    $ cd emsdk
    
    # Fetch the latest version of the emsdk (not needed the first time you clone)
    $ git pull
    
    # Download and install the latest SDK tools.
    $ ./emsdk install latest
    
    # Make the "latest" SDK "active" for the current user. (writes .emscripten file)
    $ ./emsdk activate latest
    
    # Activate PATH and other environment variables in the current terminal
    $ source ./emsdk_env.sh
    

    To ensure that you have install Emscripten successfully, you can create a folder with a file:

    $ mkdir hello
    $ cd hello
    $ echo '#include <stdio.h>' > hello.c
    $ echo 'int main(int argc, char ** argv) {' >> hello.c
    $ echo 'printf("Hello, world!\n");' >> hello.c
    $ echo '}' >> hello.c
    $ emcc hello.c -s WASM=1 -o hello.html
    $ python -m SimpleHTTPServer 1111 # for python2
    $ python -m http.server 1111 # for python3
    # open your browser, and open http://localhost:1111/hello.html
    

    Then you can start a localhost server to view the html.

  • Build ogdf library.

    # cd to ~/packages/ogdf.js
    $ cd ../../ogdf.js
    $ cd packages/ogdf.js/ogdf
    $ mkdir build && cd build
    $ emcmake cmake ..
    $ emmake make
    

    Everytime you restart your OS, you should run ./emsdk activate latest and source ./emsdk_env.sh in step one the ensure your environment is correct

    For the "this header is only for x86 only" error, please refer to: emscripten-issue-9363

  • Build rawogdf.js

    # cd to ~/packages/ogdf.js
    $ cd ../..
    $ make rawogdf.js
    
  • Build ogdf.js

    # cd to ~/
    $ cd ../..
    $ npm install
    $ npm run bootstrap
    $ npm run build
    # open dashboard
    $ npm run watch:dashboard
    

Server & Testing

$ npm run test # run all tests
$ npm run server # open a local http server to see examples
$ npm run watch:dashboard # to open the dashboard

Progress

  • add other layout algorithms

Keywords

graph

FAQs

Package last updated on 04 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts