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

graphology-operators

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-operators - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

to-undirected.d.ts

1

index.d.ts
export {default as reverse} from './reverse.js';
export {default as toSimple} from './to-simple.js';
export {default as toUndirected} from './to-undirected.js';
export {default as union} from './union.js';

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

exports.toSimple = require('./to-simple.js');
exports.toUndirected = require('./to-undirected.js');
exports.union = require('./union.js');

11

package.json
{
"name": "graphology-operators",
"version": "0.2.0",
"version": "1.0.0",
"description": "Miscellaneous operators for graphology.",

@@ -10,2 +10,3 @@ "main": "index.js",

"reverse.js",
"to-undirected.js",
"to-simple.js",

@@ -41,4 +42,4 @@ "union.js"

"eslint": "^6.8.0",
"graphology": "^0.15.0",
"mocha": "^7.0.1"
"graphology": "^0.16.0",
"mocha": "^7.1.0"
},

@@ -49,5 +50,5 @@ "eslintConfig": {

"dependencies": {
"graphology-types": "^0.15.0",
"graphology-utils": "^1.1.1"
"graphology-types": "^0.16.0",
"graphology-utils": "^1.7.0"
}
}

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

* [toSimple](#tosimple)
* [toUndirected](#toundirected)

@@ -65,3 +66,3 @@ ### reverse

If a simple graph is passed, the function will only return a copy of it.
If an already simple graph is passed, the function will only return a copy of it.

@@ -75,1 +76,31 @@ ```js

```
### toUndirected
Returns the undirected version of the given graph where any directed edge will be considered as now undirected.
Note that you can pass a function to merge edge attributes in case of mutual edges or mixed edges conflicts. This can be useful to sum weights and so on...
If an already undirected graph is passed, the function will only return a copy of it.
```js
import {toUndirected} from 'graphology-operators';
// Alternatively, to load only the relevant code:
import toUndirected from 'graphology-operators/to-undirected';
const undirectedGraph = toUndirected(graph);
// Using a merging function
const undirectedGraph = toUndirected(graph, (currentAttr, nextAttr) => {
return {
...currentAttr,
weight: currentAttr.weight + nextAttr.weight
};
});
```
*Arguments*
* **graph** *Graph*: target graph.
* **mergeOrOptions** *?function|object*: either a merging function or an options object:
* **mergeEdge** *?function*: merging function to use.

@@ -19,7 +19,2 @@ /**

// Importing the nodes
graph.forEachNode(function(n, a) {
reversed.addNode(n, a);
});
// Importing undirected edges

@@ -26,0 +21,0 @@ graph.forEachUndirectedEdge(function(e) {

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

if (!isGraph(multiGraph))
throw new Error('graphology-operators/cast/toSimple: expecting a valid graphology instance.');
throw new Error('graphology-operators/to-simple: expecting a valid graphology instance.');

@@ -21,7 +21,2 @@ // The graph is not multi. We just return a plain copy

// First we need to add nodes
multiGraph.forEachNode(function(node, attr) {
graph.addNode(node, attr);
});
// Then we need to process edges

@@ -28,0 +23,0 @@ multiGraph.forEachDirectedEdge(function(edge, attr, source, target) {

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