graphology-assertions
v2.2.1
Published
Assertions for graphology.
Downloads
3,388
Maintainers
Readme
Graphology Assertions
Assertions to be used with graphology
.
Installation
npm install graphology-assertions
Usage
- #.isGraph
- #.isGraphConstructor
- #.haveSameNodes
- #.haveSameNodesDeep
- #.areSameGraphs
- #.areSameGraphsDeep
- #.haveSameEdges
- #.haveSameEdgesDeep
#.isGraph
Function returning whether the given value is a graphology
implementation's instance.
import {isGraph} from 'graphology-assertions';
const graph = new Graph();
isGraph(graph);
>>> true
isGraph(45);
>>> false
isGraph({hello: 'world'});
>>> false
Arguments
- value any: value to test.
#.isGraphConstructor
Function returning whether the given value is a graphology
constructor.
import {isGraphConstructor} from 'graphology-assertions';
isGraphConstructor(Graph);
>>> true
isGraphConstructor(45);
>>> false
isGraphConstructor(new Graph());
>>> false
Arguments
- value any: value to test.
#.haveSameNodes
Returns whether two graphs have the same nodes.
import {haveSameNodes} from 'graphology-assertions';
haveSameNodes(G, H);
#.haveSameNodesDeep
Returns whether two graphs have the same nodes & whether those nodes have the same attributes.
import {haveSameNodesDeep} from 'graphology-assertions';
haveSameNodesDeep(G, H);
#.areSameGraphs
Returns whether two graphs are the same.
import {areSameGraphs} from 'graphology-assertions';
areSameGraphs(G, H);
#.areSameGraphsDeep
Returns whether two graphs as well as their node & edge attributes are the same.
import {areSameGraphsDeep} from 'graphology-assertions';
areSameGraphsDeep(G, H);
#.haveSameEdges
Returns whether two graphs have the same edges. Note that it implies that both graphs' nodes are also the same.
This is different than areSameGraphs because it will allow different graph types to be compared, e.g. a mixed graph and a directed one having the same edges nonetheless.
import {haveSameEdges} from 'graphology-assertions';
haveSameEdges(G, H);
#.haveSameEdgesDeep
Returns whether two graphs have the same edges & whether those edges have the same attributes. Note that it implies that both graphs' nodes are also the same.
This is different than areSameGraphsDeep because it will allow different graph types to be compared, e.g. a mixed graph and a directed one having the same edges nonetheless.
import {haveSameEdgesDeep} from 'graphology-assertions';
haveSameEdgesDeep(G, H);