graphology-metrics
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -15,7 +15,7 @@ /** | ||
* | ||
* @param {boolean} assign - Whether to assign the result to the nodes. | ||
* @param {string} method - Method of the graph to get the degree. | ||
* @param {Graph} graph - A graphology instance. | ||
* @param {object} [options] - Options: | ||
* @param {string} [attribute] - Name of the attribute to assign. | ||
* @param {boolean} assign - Whether to assign the result to the nodes. | ||
* @param {string} method - Method of the graph to get the degree. | ||
* @param {Graph} graph - A graphology instance. | ||
* @param {object} [options] - Options: | ||
* @param {string} [attribute] - Name of the attribute to assign. | ||
*/ | ||
@@ -22,0 +22,0 @@ function abstractDegreeCentrality(assign, method, graph, options) { |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
exports.betweenness = require('./betweenness.js'); | ||
exports.degree = require('./degree.js'); |
{ | ||
"name": "graphology-metrics", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Miscellaneous graph metrics for graphology.", | ||
@@ -11,5 +11,5 @@ "main": "index.js", | ||
"scripts": { | ||
"lint": "eslint *.js centrality/*.js test/*.js", | ||
"lint": "eslint **/*.js", | ||
"prepublish": "npm run lint && npm test", | ||
"test": "mocha test" | ||
"test": "mocha --recursive test" | ||
}, | ||
@@ -48,4 +48,5 @@ "repository": { | ||
"eslint": "^4.18.2", | ||
"graphology": "^0.11.1", | ||
"mocha": "^4.1.0" | ||
"graphology": "^0.11.2", | ||
"graphology-generators": "^0.9.0", | ||
"mocha": "^5.0.4" | ||
}, | ||
@@ -56,5 +57,6 @@ "eslintConfig": { | ||
"dependencies": { | ||
"graphology-utils": "^1.1.1", | ||
"graphology-shortest-path": "^1.0.1", | ||
"graphology-utils": "^1.3.0", | ||
"lodash": "^4.17.5" | ||
} | ||
} |
@@ -24,2 +24,3 @@ [![Build Status](https://travis-ci.org/graphology/graphology-metrics.svg)](https://travis-ci.org/graphology/graphology-metrics) | ||
* [Centrality](#centrality) | ||
- [Betweenness centrality](#betweenness-centrality) | ||
- [Degree centrality](#degree-centrality) | ||
@@ -119,2 +120,32 @@ | ||
#### Betweenness centrality | ||
Computes the betweenness centrality for every node. | ||
```js | ||
import betweennessCentrality from 'graphology-metrics/centrality/betweenness'; | ||
// To compute centrality for every node: | ||
const centrality = betweennessCentrality(graph); | ||
// To compute weighted betweenness centrality | ||
const centrality = betweennessCentrality(graph, {weighted: true}); | ||
// To directly map the result onto nodes' attributes (`beetweennessCentrality`): | ||
betweennessCentrality.assign(graph); | ||
// To directly map the result onto a custom attribute: | ||
betweennessCentrality.assign(graph, {attributes: 'myCentrality'}); | ||
``` | ||
*Arguments* | ||
* **graph** *Graph*: target graph. | ||
* **options** *?object*: options: | ||
* **attributes** *?object*: Custom attribute names: | ||
- **centrality** *?string* [`betweennessCentrality`]: Name of the centrality attribute to assign. | ||
- **weight** *?string*: Name of the weight attribute. | ||
* **normalized** *?boolean* [`true`]: should the result be normalized? | ||
* **weighted** *?boolean* [`false`]: should we compute the weighted betweenness centrality? | ||
#### Degree centrality | ||
@@ -133,4 +164,4 @@ | ||
// To get centralities for every node: | ||
const centralities = degreeCentrality(graph); | ||
// To compute degree centrality for every node: | ||
const centrality = degreeCentrality(graph); | ||
@@ -137,0 +168,0 @@ // To directly map the result onto nodes' attributes (`degreeCentrality`): |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22946
10
511
177
3
6
+ Added@yomguithereal/helpers@1.1.1(transitive)
+ Addedgraphology-indices@0.16.6(transitive)
+ Addedgraphology-shortest-path@1.5.2(transitive)
+ Addedgraphology-utils@2.5.2(transitive)
+ Addedmnemonist@0.38.50.39.8(transitive)
+ Addedobliterator@2.0.4(transitive)
Updatedgraphology-utils@^1.3.0