iper
Hypergraphs for breakfast!
Installation | API | Examples | License
Installation
With npm do
npm install iper
API
new Graph([graph])
Hypergraph constructor.
const Graph = Graph const 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 have the same cardinality (i.e. number of nodes)
graph.addEdge(nodeIds)
Add an hyperedge that connects given nodeIds.
- @param
{Array}
nodeIds - @returns
{String}
id
graph.addNode(data)
Add a node, containing given data.
var nodeId = graph
- @param
{*}
[data] - @returns
{String}
id of the node created
graph.degreeOf(nodeId)
Returns the degree of a node, that is the number of incident edges with loops counted twice.
- @param
{String}
id - @returns
{void}
graph.delEdge(edgeId)
Delete edge by given id.
The node id will be removed from every edge connected. If some edge after this operation will result having only one or zero vertices left, it will be removed too.
- @param
{String}
edgeId - @returns
{void}
graph.delNode(nodeId)
Delete node by given id.
- @param
{String}
nodeId - @returns
{void}
graph.generateId()
Returns a random string to be used as id.
- @returns
{String}
Override this method if you want to customize how ids are generated, for example
const uniqueid = const Graph = Graph { return } moduleexports = MyGraph
graph.getRank()
Returns the max cardinality of any of the edges in the hypergraph.
- @returns
{Number}
Examples
Classic graph
const Graph = Graph const classicGraph = uniform: 2