Skip to content

koustuvsinha/networkjs

Repository files navigation

NetworkJS Build Status

NetworkX clone in JavaScript!

Implemented modules :

  • Degree Centrality
  • Betweenness Centrality
  • Eigenvector Centrality

Menu

Installation

  • Install Nodejs
  • For command line install the tool via npm : npm install -g networkjs
  • For library usage : npm install --save networkjs
  • Makefile is also provided which will automatically install latest node if not present and then install the command line tool. To run, type the following :
make
make install

Usage

Command Line

See full options available : networkjs --help

  • -s,--source : Provide the column name for Source Node. Default value = "Source"

  • -t,--target : Provide the column name for Target Node. Default value = "Target"

  • -w,--weight : Provide the column name for Weight Node. Default value = "Weight"

  • -d,--degree: Run Degree centrality measure over the given dataset, which is defined as the number of links incident upon a node. https://en.wikipedia.org/wiki/Centrality#Degree_centrality

  • -b,--betweenness: Run Betweenness centrality measure over the given dataset, which for a node is defined as the number of times a node acts as a bridge along the shortest path between two other nodes. https://en.wikipedia.org/wiki/Centrality#Betweenness_centrality

  • -e,--eigenvector: Run Eigenvector centrality measure over the given dataset, which calculates the influence of a node in the network. It assigns relative scores to all nodes in the network based on the concept that connections to high-scoring nodes contribute more to the score of the node in question than equal connections to low-scoring nodes. https://en.wikipedia.org/wiki/Centrality#Eigenvector_centrality

  • -v,--verbose: Print detailed logs and events

  • -h,--help: Display command line help usage for the methods available

For more details consult the man page : man networkjs

Library Usage

Import the required modules either using AMD require or ES6 import :

import nj from 'networkjs'
const Graph = nj.datastructures.Graph
const {betweenness_centrality,
  degree_centrality,
  eigenvector_centrality} = nj.algorithms.centrality

// Add edges
let G = new Graph()
G.add_edges_from([[1,2],[2,3]])

API Reference

datastructures.Graph

  • read_csv
  • add_node
  • add_nodes_from
  • remove_node
  • get_node
  • order
  • has_node
  • num_nodes
  • get_nodes
  • is_directed
  • add_edge
  • add_edges_from
  • add_weighted_edges_from
  • remove_edge
  • remove_edges_from
  • has_edge
  • neighbors
  • degree_iter
  • nbunch_iter

algorithms.centrality

Run Tests

npm test

Change Log

0.1.1

  • Changed the command line usage for providing Source, Target and Weight column headers

0.1.0

  • Updated command line interface, now provide Source, Target and Weight headers directly
  • Command line output in csv by default. To get json output provide flag --json

0.0.7

0.0.6

  • Patch fix again broken library import

0.0.5

  • Patch fix broken library import

0.0.4

  • Experimental Library Support

0.0.3

  • Minor fixes
  • Better readme
  • Project is now public

0.0.2

  • Published as npm package
  • Supports command line features

0.0.1

  • Initial release, supports Degree centrality, Betweenness centrality and Eigenvector centrality
  • Added Tests

License

MIT