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.12.0 to 1.13.0

diameter.d.ts

2

index.d.ts
export {default as centrality} from './centrality';
export {default as density} from './density';
export {default as diameter} from './diameter';
export {default as eccentricity} from './eccentricity';
export {default as extent} from './extent';

@@ -4,0 +6,0 @@ export {default as layoutQuality} from './layout-quality';

@@ -9,2 +9,4 @@ /**

exports.density = require('./density.js');
exports.diameter = require('./diameter.js');
exports.eccentricity = require('./eccentricity.js');
exports.extent = require('./extent.js');

@@ -11,0 +13,0 @@ exports.layoutQuality = require('./layout-quality');

{
"name": "graphology-metrics",
"version": "1.12.0",
"version": "1.13.0",
"description": "Miscellaneous graph metrics for graphology.",

@@ -25,2 +25,4 @@ "main": "index.js",

"density",
"diameter",
"eccentricity",
"extent",

@@ -40,2 +42,6 @@ "graph",

"url": "https://github.com/luccitan"
},
{
"name": "Pauline Breteau",
"url": "https://github.com/paubre"
}

@@ -42,0 +48,0 @@ ],

197

README.md

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

* [Density](#density)
* [Diameter](#diameter)
* [Extent](#extent)

@@ -25,6 +26,7 @@ * [Modularity](#modularity)

* [Degree](#degree)
* [Centrality](#centrality)
- [Betweenness centrality](#betweenness-centrality)
- [Degree centrality](#degree-centrality)
* [Degree](#degree)
* [Eccentricity](#eccentricity)
* [Weighted degree](#weighted-degree)

@@ -80,2 +82,26 @@

### Diameter
Computes the diameter, i.e the maximum eccentricity of any node of the given graph.
```js
import {diameter} from 'graphology-metrics';
// Alternatively, to load only the relevant code:
import diameter from 'graphology-metrics/diameter';
const graph = new Graph();
graph.addNode('1');
graph.addNode('2');
graph.addNode('3');
graph.addUndirectedEdge(1, 2);
graph.addUndirectedEdge(2, 3);
diameter(graph);
>>> 2
```
*Arguments*
* **graph** *Graph*: target graph.
### Extent

@@ -128,6 +154,7 @@

* **options** *?object*: options:
* **communities** *?object*: object mapping nodes to their respective communities.
* **attributes** *?object*: attributes' names:
* **community** *?string* [`community`]: name of the nodes' community attribute in case we need to read them from the graph itself.
* **weight** *?string* [`weight`]: name of the edges' weight attribute.
* **communities** *?object*: object mapping nodes to their respective communities.
* **resolution** *?number*: resolution parameter (`γ`).
* **weighted** *?boolean* [`true`]: whether to compute weighted modularity or not.

@@ -162,71 +189,2 @@

### Degree
Returns degree information for every node in the graph. Note that [`graphology`](https://graphology.github.io)'s API already gives you access to this information through `#.degree` etc. So only consider this function as a convenience to extract/assign all degrees at once.
```js
import degree from 'graphology-metrics/degree';
import degree, {
inDegree,
outDegree,
undirectedDegree,
directedDegree,
allDegree
} from 'graphology-metrics/degree';
// To extract degree information for every node
const degrees = degree(graph);
>>> {node1: 34, node2: 45, ...}
// To extract only in degree information for every node
const inDegrees = inDegree(graph);
// To extract full degree breakdown for every node
const degrees = allDegree(graph);
>>> { // Assuming the graph is directed
node1: {
inDegree: 2,
outDegree: 36
},
...
}
// To map degree information to node attributes
degree.assign(graph);
graph.getNodeAttribute(node, 'degree');
>>> 45
// To map only degree & in degree to node attributes
allDegree.assign(graph, {types: ['degree', 'inDegree']});
// To map only degree & in degree with different names
allDegree(
graph,
{
attributes: {
inDegree: 'in',
outDegree: 'out'
},
types: ['inDegree', 'outDegree']
}
)
>>> {
1: {in: 1, out: 1},
...
}
```
*Arguments*
* **graph** *Graph*: target graph.
* **options** *?object*: options:
- **attributes** *?object*: Custom attribute names:
+ **degree** *?string*: Name of the mixed degree attribute.
+ **inDegree** *?string*: Name of the mixed inDegree attribute.
+ **outDegree** *?string*: Name of the mixed outDegree attribute.
+ **undirectedDegree** *?string*: Name of the mixed undirectedDegree attribute.
+ **directedDegree** *?string*: Name of the mixed directedDegree attribute.
- **types** *?array*: List of degree types to extract.
### Centrality

@@ -340,2 +298,99 @@

### Degree
Returns degree information for every node in the graph. Note that [`graphology`](https://graphology.github.io)'s API already gives you access to this information through `#.degree` etc. So only consider this function as a convenience to extract/assign all degrees at once.
```js
import degree from 'graphology-metrics/degree';
import degree, {
inDegree,
outDegree,
undirectedDegree,
directedDegree,
allDegree
} from 'graphology-metrics/degree';
// To extract degree information for every node
const degrees = degree(graph);
>>> {node1: 34, node2: 45, ...}
// To extract only in degree information for every node
const inDegrees = inDegree(graph);
// To extract full degree breakdown for every node
const degrees = allDegree(graph);
>>> { // Assuming the graph is directed
node1: {
inDegree: 2,
outDegree: 36
},
...
}
// To map degree information to node attributes
degree.assign(graph);
graph.getNodeAttribute(node, 'degree');
>>> 45
// To map only degree & in degree to node attributes
allDegree.assign(graph, {types: ['degree', 'inDegree']});
// To map only degree & in degree with different names
allDegree(
graph,
{
attributes: {
inDegree: 'in',
outDegree: 'out'
},
types: ['inDegree', 'outDegree']
}
)
>>> {
1: {in: 1, out: 1},
...
}
```
*Arguments*
* **graph** *Graph*: target graph.
* **options** *?object*: options:
- **attributes** *?object*: Custom attribute names:
+ **degree** *?string*: Name of the mixed degree attribute.
+ **inDegree** *?string*: Name of the mixed inDegree attribute.
+ **outDegree** *?string*: Name of the mixed outDegree attribute.
+ **undirectedDegree** *?string*: Name of the mixed undirectedDegree attribute.
+ **directedDegree** *?string*: Name of the mixed directedDegree attribute.
- **types** *?array*: List of degree types to extract.
### Eccentricity
Computes the eccentricity which is the maximum of the shortest paths between the given node and any other node.
```js
import {eccentricity} from 'graphology-metrics';
// Alternatively, to load only the relevant code:
import eccentricity from 'graphology-metrics/eccentricity';
graph.addNode('1');
graph.addNode('2');
graph.addNode('3');
graph.addNode('4');
graph.addUndirectedEdge(1, 2);
graph.addUndirectedEdge(2, 3);
graph.addUndirectedEdge(3, 1);
graph.addUndirectedEdge(3, 4);
eccentricity(graph, 3)
>> 1
```
*Arguments*
* **graph** *Graph*: target graph.
* **node** *any*: desired node.
### Modalities

@@ -342,0 +397,0 @@

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