@kingjs/poset.encode

Encodes an adjacency list and vertex property map into a descriptor whose property names, when split on `$`, reveal a vertex name followed by its adjacent vertices, and whose property values correspond to vertex properties.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
03Jun 12, 2021Jul 20, 2018Minified + gzip package size for @kingjs/poset.encode in KB

Readme

@kingjs/poset.encode

Encodes properties of vertices and their adjacent vertices into a descriptor.

Usage

Encode a poset where vertex 'a' has value 1 and depends on 'b' and 'c' which have values 2 and 3 respectively, and both depend on 'd' which has value 4, like this:

var encode = require('@kingjs/poset.encode');

//   a=1
//   / \
// b=2 c=3
//   \ /
//   d=4
encode.call({
  a: [ 'b', 'c' ],
  b: [ 'd' ],
  c: [ 'd' ],
}, {
  a: 1,
  b: 2,
  c: 3,
  d: 4
});

result:

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

API

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

Interfaces

  • EncodedPoset: see @kingjs/poset
  • VertexProperties: see @kingjs/poset
  • AdjacencyList: see @kingjs/poset

    Parameters

  • this: A descriptor whose properties are vertex names and whose values are vertex properties.
  • edges: A descriptor whose properties are vertex names and whose values are arrays containing the names of adjacent vertices.

    Returns

    Returns a descriptor whose every property name is a join by '$' of a vertex name followed by its adjacent vertices.

    Install

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

    License

    MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.