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.5.0 to 1.6.0

weighted-degree.js

1

centrality/degree.js

@@ -20,2 +20,3 @@ /**

* @param {string} [attribute] - Name of the attribute to assign.
* @return {object|void}
*/

@@ -22,0 +23,0 @@ function abstractDegreeCentrality(assign, method, graph, options) {

@@ -11,1 +11,3 @@ /**

exports.modularity = require('./modularity.js');
exports.weightedDegree = require('./weighted-degree.js');
exports.weightedSize = require('./weighted-size.js');

2

package.json
{
"name": "graphology-metrics",
"version": "1.5.0",
"version": "1.6.0",
"description": "Miscellaneous graph metrics for graphology.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -20,2 +20,3 @@ [![Build Status](https://travis-ci.org/graphology/graphology-metrics.svg)](https://travis-ci.org/graphology/graphology-metrics)

* [Modularity](#modularity)
* [Weighted size](#weighted-size)

@@ -27,2 +28,3 @@ *Node metrics*

- [Degree centrality](#degree-centrality)
* [Weighted degree](#weighted-degree)

@@ -119,2 +121,29 @@ ### Density

### Weighted size
Computes the weighted size, i.e. the sum of the graph's edges' weight, of the given graph.
```js
import {weightedSize} from 'graphology-metrics';
// Alternatively, to load only the relevant code:
import weightedSize from 'graphology-metrics/weighted-size';
const graph = new Graph();
graph.mergeEdge(1, 2, {weight: 3});
graph.mergeEdge(1, 2, {weight: 1});
// Simplest way
weightedSize(graph);
>>> 4
// With custom weight attribute
weightedSize(graph, 'myWeightAttribute');
>>> 4
```
*Arguments*
* **graph** *Graph*: target graph.
* **weightAttribute** *?string* [`weight`]: name of the weight attribute.
### Centrality

@@ -180,1 +209,48 @@

* **attribute** *?string*: name of the centrality attribute.
### Weighted degree
Computes the weighted degree of nodes. The weighted degree of a node is the sum of its edges' weights.
```js
import weightedDegree from 'graphology-metrics/weighted-degree';
// Or to load more specific functions:
import {
weightedDegree,
weightedInDegree,
weightedOutDegree
} from 'graphology-metrics/weighted-degree';
// To compute weighted degree of a single node
weightedDegree(graph, 'A');
// To compute weighted degree of every node
const weightedDegrees = weightedDegree(graph);
// To compute normalized weighted degree, i.e. weighted degree will be
// divided by the node's relevant degree
weightedDegree(graph, 'A', {normalized: true});
// To directly map the result onto node attributes
weightedDegree.assign(graph);
```
*Arguments*
To compute the weighted degree of a single node:
* **graph** *Graph*: target graph.
* **node** *any*: desired node.
* **options** *?object*: options. See below.
To compute the weighted degree of every node:
* **graph** *Graph*: target graph.
* **options** *?object*: options. See below.
*Options*
* **attributes** *?object*: custom attribute names:
- **weight** *?string* [`weight`]: name of the weight attribute.
- **weightedDegree** *?string* [`weightedDegree`]: name of the attribute to assign.
* **averaged** *?boolean* [`false`]: return averaged weighted degree.
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