npm.io
1.0.0 • Published 9 years ago

matrix-generator

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0

matrix-generator

Simple generator of matrix.

Installation

npm i matrix-generator --save

Usage

const mGenerator = require('matrix-generator')
const matrix = []
const feature = ['red', 'green']

matrix[0] = 5                                 // amount
matrix[1] = [4, 7, 2, 5, 12]                  // value
matrix[2] = [0, 1, 0, 0, 1]                   // feature
matrix[3] = [[1, 2], [1, 3], [3, 4], [3, 5]]  // relationship (from, to)

const output = mGenerator(matrix, feature)

console.log('- output -----------------------------------------------------------')
console.log(output)
console.log('--------------------------------------------------------------------')
Output
- output -----------------------------------------------------------
[ [ 4, 'red', [ 1, 2 ] ],
  [ 7, 'green' ],
  [ 2, 'red', [ 3, 4 ] ],
  [ 5, 'red' ],
  [ 12, 'green' ] ]
--------------------------------------------------------------------

Keywords