Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphology-metrics

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-metrics - npm Package Compare versions

Comparing version 1.8.0-alpha1 to 1.8.0-alpha2

52

centrality/betweenness.js

@@ -8,6 +8,8 @@ /**

var isGraph = require('graphology-utils/is-graph'),
unweightedShortestPath = require('graphology-shortest-path/unweighted'),
dijkstraShotestPath = require('graphology-shortest-path/dijkstra'),
lib = require('graphology-shortest-path/indexed-brandes'),
defaults = require('lodash/defaults');
var createUnweightedIndexedBrandes = lib.createUnweightedIndexedBrandes,
createDijkstraIndexedBrandes = lib.createDijkstraIndexedBrandes;
/**

@@ -42,4 +44,2 @@ * Defaults.

var centralities = {};
// Solving options

@@ -53,8 +53,9 @@ options = defaults({}, options, DEFAULTS);

/* eslint no-unused-vars: 0 */
var shortestPath = unweightedShortestPath.createIndexedBrandes(graph);
var brandes = weighted ?
createDijkstraIndexedBrandes(graph, weightAttribute) :
createUnweightedIndexedBrandes(graph);
var nodes = graph.nodes(),
node,
result,
var N = graph.order;
var result,
S,

@@ -66,3 +67,2 @@ P,

j,
l,
m,

@@ -72,14 +72,9 @@ v,

var delta = {};
var delta = new Float64Array(N),
centralities = new Float64Array(N);
// Initializing centralities
for (i = 0, l = nodes.length; i < l; i++)
centralities[nodes[i]] = 0;
// Iterating over each node
for (i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
for (i = 0; i < N; i++) {
result = brandes(i);
result = shortestPath(node);
S = result[0];

@@ -104,3 +99,3 @@ P = result[1];

if (w !== node)
if (w !== i)
centralities[w] += delta[w];

@@ -111,7 +106,6 @@ }

// Rescaling
var n = graph.order,
scale = null;
var scale = null;
if (normalized)
scale = n <= 2 ? null : (1 / ((n - 1) * (n - 2)));
scale = N <= 2 ? null : (1 / ((N - 1) * (N - 2)));
else

@@ -121,12 +115,10 @@ scale = graph.type === 'undirected' ? 0.5 : null;

if (scale !== null) {
for (node in centralities)
centralities[node] *= scale;
for (i = 0; i < N; i++)
centralities[i] *= scale;
}
if (assign) {
for (node in centralities)
graph.setNodeAttribute(node, centralityAttribute, centralities[node]);
}
if (assign)
return brandes.index.assign(centralityAttribute, centralities);
return centralities;
return brandes.index.collect(centralities);
}

@@ -133,0 +125,0 @@

{
"name": "graphology-metrics",
"version": "1.8.0-alpha1",
"version": "1.8.0-alpha2",
"description": "Miscellaneous graph metrics for graphology.",

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

"keywords": [
"betweenness",
"centrality",

@@ -60,6 +61,9 @@ "density",

]
},
"globals": {
"Float64Array": true
}
},
"dependencies": {
"graphology-shortest-path": "1.1.0-alpha1",
"graphology-shortest-path": "^1.1.1",
"graphology-types": "^0.15.4",

@@ -66,0 +70,0 @@ "graphology-utils": "^1.6.1",

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