JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19910
  • Score
    100M100P100Q158569F
  • License MIT

Miscellaneous operators for graphology.

Package Exports

  • graphology-operators

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (graphology-operators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

Graphology Operators

Miscellaneous operators to be used with graphology.

Installation

npm install graphology-operators

Usage

Unary

Binary

Cast

reverse

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

  • graph Graph: target graph.

union

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

  • G Graph: first graph.
  • H Graph: second graph.

toSimple

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);

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.

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.