node package manager

iper

Hypergraphs for breakfast

iper

Hypergraphs for breakfast!

With npm do

npm install iper

With bower do

bower install iper

Hypergraph constructor.

const Graph = require('iper').Graph
 
const graph = new Graph()
  • @param {Object} [graph]
  • @param {Object} [graph.edges]
  • @param {Object} [graph.nodes]
  • @param {Boolean} [graph.multigraph] can contain duplicated edges
  • @param {Boolean} [graph.pseudograph] is a multigraph with loops allowed
  • @param {Number} [graph.uniform] all edges has the same cardinality (i.e. number of nodes)

Add an hyperedge that connects given nodeIds.

  • @param {Array} nodeIds
  • @returns {String} id

Add a node, containing given data.

var nodeId = graph.addNode({ label: 'foo' })
  • @param {*} [data]
  • @returns {String} id of the node created

Returns the degree of a node, that is the number of incident edges with loops counted twice.

  • @param {String} id
  • @returns {void}

Delete edge by given id.

  • @param {String} id
  • @returns {void}

Delete node by given id.

  • @param {String} id
  • @returns {void}

Returns a random string to be used as id.

  • @returns {String}

Override this methos if you want to customize how ids look like, for example

const uniqueid = require('lodash.uniqueid')
const Graph = require('iper').Graph
 
class MyGraph extends Graph {
  generateId () {
    return uniqueid()
  }
}
 
module.exports = MyGraph

Returns the max cardinality of any of the edges in the hypergraph.

  • @returns {Number}

MIT