@kingjs/poset.decode

1.0.10 • Public • Published

@kingjs/poset.decode

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

Dependents (2)

Package Sidebar

Install

npm i @kingjs/poset.decode

Weekly Downloads

0

Version

1.0.10

License

MIT

Unpacked Size

3.8 kB

Total Files

4

Last publish

Collaborators

  • kingces95