@kingjs/poset.decode

Decodes a descriptor representing a poset into an adjacency list and a vertex property map.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/poset.decode
091.0.104 years ago4 years agoMinified + gzip package size for @kingjs/poset.decode in KB

Readme

Decodes a descriptor representing a poset into an adjacency list and a vertex property map.

Usage

Decode an encoded poset with exported vertices 'a', 'b', and 'c' where vertex 'a' has value 1, and depends on vertices 'b' and 'c' which have values 2 and 3 respectively, and both depend on 'd' which has value 4, like this:
var decode = require('@kingjs/poset.decode');

var vertices = { };
//   a=1
//   / \
// b=2 c=3
//   \ /
//   d=4
var result = {
  edges: decode.call({
    a$b$c: 1,
    b$d: 2,
    c$d: 3,
    d: 4,
  }, vertices),
  
  vertices: vertices
}
result:
{
  edges: {
    a: [ 'b', 'c' ],
    b: [ 'd' ],
    c: [ 'd' ]
  },

  vertices: {
    a: 1,
    b: 2,
    c: 3,
    d: 4
  }
}

API

declare function decode(
  this: EncodedPoset,
  vertices: VertexProperties
): AdjacencyList

Interfaces

Parameters

  • this: An encoded poset.
  • vertices: A out descriptor augmented with vertex properties.

Returns

An descriptor with a property for every vertex that has adjacent vertices. Each property value is an array of names of the adjacent vertices.

Install

With npm installed, run
$ npm install @kingjs/poset.decode

License

MIT
Analytics
poset: https://www.npmjs.com/package/@kingjs/poset