New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphology-communities-louvain

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-communities-louvain - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

71

index.js

@@ -61,2 +61,5 @@ /**

var weightAttribute = options.attributes.weight,
communityAttribute = options.attributes.community;
var nodes = graph.nodes(),

@@ -86,3 +89,2 @@ edges,

oldc, newc,
stack,
visited;

@@ -93,4 +95,4 @@

j, l2,
k, l3,
keys,
iterator,
step,
node, node2, edge, edge2, bounds,

@@ -121,4 +123,3 @@ community, community2;

belongings[node] = node;
possessions[node] = {};
possessions[node][node] = true;
possessions[node] = new Set([node]);
indegree[node] = 0;

@@ -130,3 +131,3 @@ outdegree[node] = 0;

bounds = pgraph.extremities(edge);
w = pgraph.getEdgeAttribute(edge, options.attributes.weight);
w = pgraph.getEdgeAttribute(edge, weightAttribute);
weight = isNaN(w) ? 1 : w;

@@ -173,5 +174,6 @@ weights[edge] = weight;

// Computing current community values
stack = Object.keys(possessions[community]);
for (j = 0, l2 = stack.length; j < l2; j++) {
node2 = stack[j];
iterator = possessions[community].values();
while ((step = iterator.next(), !step.done)) {
node2 = step.value;
if (node !== node2) {

@@ -199,5 +201,6 @@ oldc.in += indegree[node2];

stack = Object.keys(possessions[community2]);
for (k = 0, l3 = stack.length; k < l3; k++) {
node2 = stack[k];
iterator = possessions[community2].values();
while ((step = iterator.next(), !step.done)) {
node2 = step.value;
newc.in += indegree[node2];

@@ -224,8 +227,10 @@ newc.out += outdegree[node2];

altered.curr[nextCommunity] = true;
delete possessions[community][node];
if (Object.keys(possessions[community]).length === 0)
possessions[community].delete(node);
if (!possessions[community].size)
delete possessions[community];
belongings[node] = nextCommunity;
possessions[nextCommunity][node] = node;
possessions[nextCommunity].add(node);
}

@@ -243,9 +248,8 @@ }

if (enhancingPass) {
bgraph = pgraph.emptyCopy();
bgraph = pgraph.nullCopy();
bgraph.upgradeToMixed();
// Adding the nodes
keys = Object.keys(possessions);
for (i = 0, l1 = keys.length; i < l1; i++)
bgraph.addNode(keys[i]);
for (node in possessions)
bgraph.addNode(node);

@@ -264,4 +268,4 @@ // Adding the edges

else {
weight = bgraph.getEdgeAttribute(edge2, options.attributes.weight);
bgraph.setEdgeAttribute(edge2, options.attributes.weight, weight + w);
weight = bgraph.getEdgeAttribute(edge2, weightAttribute);
bgraph.setEdgeAttribute(edge2, weightAttribute, weight + w);
}

@@ -274,4 +278,4 @@

else {
weight = bgraph.getEdgeAttribute(edge2, options.attributes.weight);
bgraph.setEdgeAttribute(edge2, options.attributes.weight, weight + w);
weight = bgraph.getEdgeAttribute(edge2, weightAttribute);
bgraph.setEdgeAttribute(edge2, weightAttribute, weight + w);
}

@@ -282,5 +286,3 @@ }

// Updating the dendogram
nodes = Object.keys(dendogram);
for (i = 0, l1 = nodes.length; i < l1; i++) {
node = nodes[i];
for (node in dendogram) {
community = belongings[dendogram[node][dendogram[node].length - 1]];

@@ -295,11 +297,14 @@ dendogram[node].push(community);

nodes = Object.keys(dendogram);
// Assigning
if (assign)
for (i = 0, l1 = nodes.length; i < l1; i ++) {
node = nodes[i];
graph.setNodeAttribute(node, options.attributes.community, dendogram[node][dendogram[node].length - 1]);
}
if (assign) {
for (node in dendogram)
graph.setNodeAttribute(
node,
communityAttribute,
dendogram[node][dendogram[node].length - 1]
);
return;
}
// Standard case ; getting the final partitions from the dendogram

@@ -306,0 +311,0 @@ for (node in dendogram)

The MIT License (MIT)
Copyright (c) 2017 Guillaume Plique (Yomguithereal)
Copyright (c) 2017-2020 Guillaume Plique (Yomguithereal)

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "graphology-communities-louvain",
"version": "0.1.1",
"version": "0.2.0",
"description": "Louvain community detection for graphology.",

@@ -11,2 +11,3 @@ "main": "index.js",

"lint": "eslint *.js test/*.js",
"prepublish": "npm run lint && npm test",
"test": "mocha test"

@@ -33,12 +34,13 @@ },

"devDependencies": {
"@yomguithereal/eslint-config": "^3.0.0",
"chai": "^3.5.0",
"eslint": "^3.15.0",
"graphology": "^0.7.1",
"graphology-metrics": "^1.1.1",
"mocha": "^3.2.0"
"@yomguithereal/eslint-config": "^4.0.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"graphology": "^0.16.0",
"graphology-metrics": "1.6.1",
"mocha": "^7.1.0"
},
"dependencies": {
"graphology-utils": "^1.1.1",
"lodash": "^4.17.4"
"graphology-utils": "^1.7.0",
"lodash": "^4.17.15",
"mnemonist": "^0.32.0"
},

@@ -45,0 +47,0 @@ "eslintConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc