You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

graphology-assertions

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-assertions

Assertions for graphology.

2.2.1
latest
Version published
Weekly downloads
1.5K
-22.37%
Maintainers
1
Weekly downloads
 
Created

Graphology Assertions

Assertions to be used with graphology.

Installation

npm install graphology-assertions

Usage

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

FAQs

Package last updated on 11 Dec 2021

Did you know?

Socket

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.

Install

Related posts