
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
markov-clustering
Advanced tools
This is a simple Markov graph cluster algorithm implementation. For more information about the algorithm, see http://micans.org/mcl/.
npm install markov-clustering
The main entry point is the cluster function. It takes two arguments, an adjacency matrix graph representation and an optional options parameter.
Here's an example options object with default values:
const options = {
expandFactor: 2,
inflateFactor: 2,
maxLoops: 10,
multFactor: 1;
}
The undirected graph below is used in this example.
Create an adjacency matrix representation of your graph, this will be the input for the clustering algorithm.
Here's the adjacency matrix for the graph above:
[[0, 1, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[1, 1, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 1, 0]]
The following snippet clusters the adjacency matrix:
const mc = require('markov-clustering');
const math = require('mathjs');
const A = math.matrix([[0, 1, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[1, 1, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 1, 0]]);
console.log(mc.cluster(A));
$ node snippet.js
[ [ 0, 1, 2 ], [ 3, 4, 5 ] ]
Some basic tests are included:
npm run test
The implementation relies on http://mathjs.org/ for matrix implementation.
The implementation is largely based on Python MCL https://github.com/koteth/python_mcl.
MIT
FAQs
Markov clustering algorithm implementation
We found that markov-clustering demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.