graphology-utils
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -13,1 +13,2 @@ /** | ||
exports.mergeStar = require('./merge-star.js'); | ||
exports.subGraph = require('./subgraph.js'); |
{ | ||
"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. | ||
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
12219
11
222
174