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

graphology-utils

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-utils - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

subgraph.js

1

index.js

@@ -13,1 +13,2 @@ /**

exports.mergeStar = require('./merge-star.js');
exports.subGraph = require('./subgraph.js');

26

package.json
{
"name": "graphology-utils",
"version": "1.3.1",
"version": "1.4.0",
"description": "Miscellaneous utils for graphology.",

@@ -13,3 +13,4 @@ "main": "index.js",

"merge-path.js",
"merge-star.js"
"merge-star.js",
"subgraph.js"
],

@@ -30,6 +31,12 @@ "scripts": {

],
"author": {
"name": "Guillaume Plique",
"url": "http://github.com/Yomguithereal"
},
"contributors": [
{
"name": "Guillaume Plique",
"url": "http://github.com/Yomguithereal"
},
{
"name": "Jules Farjas",
"url": "http://github.com/farjasju"
}
],
"license": "MIT",

@@ -43,8 +50,11 @@ "bugs": {

"eslint": "^4.18.2",
"graphology": "^0.13.0",
"graphology": "^0.13.1",
"mocha": "^5.2.0"
},
"eslintConfig": {
"extends": "@yomguithereal/eslint-config"
"extends": "@yomguithereal/eslint-config",
"globals": {
"Set": true
}
}
}

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

Miscellaneous utils to be used with [`graphology`](https://graphology.github.io).
Miscellaneous utility functions to be used with [`graphology`](https://graphology.github.io).

@@ -21,2 +21,3 @@ ## Installation

* [#.mergeStar](#mergestar)
* [#.subGraph](#subgraph)

@@ -139,1 +140,37 @@ ### #.isGraph

### #.subGraph
Function returning the subgraph corresponding to the given list of nodes.
```js
import Graph from 'graphology';
import {subGraph} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import subGraph from 'graphology-utils/subgraph';
const graph = new Graph();
graph.addNode('Dale');
graph.addNode('Laura');
graph.addNode('Norma');
graph.addNode('Shelly');
graph.addEdge('Dale', 'Laura');
graph.addEdge('Dale', 'Norma');
graph.addEdge('Shelly', 'Laura');
graph.addUndirectedEdge('Norma', 'Shelly');
subGraphResult = subGraph(graph, ['Dale', 'Laura']);
subGraphResult.nodes();
>>> [ 'Dale', 'Laura' ]
subGraphResult.forEachEdge(
(edge, attributes, source, target) => {
console.log(`Edge from ${source} to ${target}`);
});
>>> 'Edge from Dale to Laura'
```
*Arguments*
* **graph** *Graph*: source graph.
* **nodes** *array|Set*: the subgraph's array or set of nodes.
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