
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
graphology-operators
Advanced tools
Miscellaneous operators to be used with graphology
.
npm install graphology-operators
Unary
Binary
Cast
Reverse the given graph's directed edges.
import {reverse} from 'graphology-operators';
// Alternatively, to load only the relevant code:
import reverse from 'graphology-operators/reverse';
const reversedGraph = reverse(graph);
Arguments
Returns the union of the given graphs. Nodes & edges present in both graph will have their attributes merges with precedence given to the second graph.
import {union} from 'graphology-operators';
// Alternatively, to load only the relevant code:
import union from 'graphology-operators/union';
const R = union(G, H);
Arguments
Returns the directed version of the given graph where any undirected edge will be now considered as mutual.
Note that you can pass a function to merge edge attributes in case of mixed edges conflicts. This can be useful to sum weights and so on...
If an already directed graph is passed, the function will only return a copy of it.
import {toDirected} from 'graphology-operators';
// Alternatively, to load only the relevant code:
import toDirected from 'graphology-operators/to-directed';
const directedGraph = toDirected(graph);
// Using a merging function
const directedGraph = toDirected(graph, (currentAttr, nextAttr) => {
return {
...currentAttr,
weight: currentAttr.weight + nextAttr.weight
};
});
Arguments
Returns the simple version of the given multigraph where we only keep a single edge of each type between nodes.
If an already simple graph is passed, the function will only return a copy of it.
import {toSimple} from 'graphology-operators';
// Alternatively, to load only the relevant code:
import toSimple from 'graphology-operators/to-simple';
const simpleGraph = toSimple(multiGraph);
Returns the undirected version of the given graph where any directed edge will be now considered as 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.
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
FAQs
Miscellaneous operators for graphology.
The npm package graphology-operators receives a total of 13,673 weekly downloads. As such, graphology-operators popularity was classified as popular.
We found that graphology-operators demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.