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

graphology-indices

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-indices - npm Package Compare versions

Comparing version 0.16.6 to 0.17.0

17

bfs-queue.d.ts

@@ -1,6 +0,17 @@

export default class BFSQueue<T = string> {
import Graph, {Attributes, NodePredicate} from 'graphology-types';
import FixedDeque from 'mnemonist/fixed-deque';
export default class BFSQueue<
T = string,
NodeAttributes extends Attributes = Attributes
> {
graph: Graph<NodeAttributes>;
size: number;
seen: Set<string>;
constructor(order: number);
seen: Set<T>;
private queue: FixedDeque<T>;
constructor(graph: Graph<NodeAttributes>);
forEachNodeYetUnseen(callback: NodePredicate<NodeAttributes>): void;
has(node: string): boolean;
hasAlreadySeenEverything(): boolean;
countUnseenNodes(): number;
push(node: string): boolean;

@@ -7,0 +18,0 @@ pushWith(node: string, item: T): boolean;

@@ -11,4 +11,5 @@ /**

function BFSQueue(order) {
this.queue = new FixedDeque(Array, order);
function BFSQueue(graph) {
this.graph = graph;
this.queue = new FixedDeque(Array, graph.order);
this.seen = new Set();

@@ -18,2 +19,29 @@ this.size = 0;

BFSQueue.prototype.hasAlreadySeenEverything = function () {
return this.seen.size === this.graph.order;
};
BFSQueue.prototype.countUnseenNodes = function () {
return this.graph.order - this.seen.size;
};
BFSQueue.prototype.forEachNodeYetUnseen = function (callback) {
var seen = this.seen;
var graph = this.graph;
graph.someNode(function (node, attr) {
// Useful early exit for connected graphs
if (seen.size === graph.order) return true; // break
// Node already seen?
if (seen.has(node)) return false; // continue
var shouldBreak = callback(node, attr);
if (shouldBreak) return true;
return false;
});
};
BFSQueue.prototype.has = function (node) {

@@ -20,0 +48,0 @@ return this.seen.has(node);

@@ -1,6 +0,16 @@

export default class DFSStack<T = string> {
import Graph, {Attributes, NodePredicate} from 'graphology-types';
export default class DFSStack<
T = string,
NodeAttributes extends Attributes = Attributes
> {
graph: Graph<NodeAttributes>;
size: number;
seen: Set<string>;
constructor(order: number);
seen: Set<T>;
private stack: Array<T>;
constructor(graph: Graph<NodeAttributes>);
forEachNodeYetUnseen(callback: NodePredicate<NodeAttributes>): void;
has(node: string): boolean;
hasAlreadySeenEverything(): boolean;
countUnseenNodes(): number;
push(node: string): boolean;

@@ -7,0 +17,0 @@ pushWith(node: string, item: T): boolean;

@@ -9,4 +9,5 @@ /**

*/
function DFSStack(order) {
this.stack = new Array(order);
function DFSStack(graph) {
this.graph = graph;
this.stack = new Array(graph.order);
this.seen = new Set();

@@ -16,2 +17,29 @@ this.size = 0;

DFSStack.prototype.hasAlreadySeenEverything = function () {
return this.seen.size === this.graph.order;
};
DFSStack.prototype.countUnseenNodes = function () {
return this.graph.order - this.seen.size;
};
DFSStack.prototype.forEachNodeYetUnseen = function (callback) {
var seen = this.seen;
var graph = this.graph;
graph.someNode(function (node, attr) {
// Useful early exit for connected graphs
if (seen.size === graph.order) return true; // break
// Node already seen?
if (seen.has(node)) return false; // continue
var shouldBreak = callback(node, attr);
if (shouldBreak) return true;
return false;
});
};
DFSStack.prototype.has = function (node) {

@@ -18,0 +46,0 @@ return this.seen.has(node);

2

package.json
{
"name": "graphology-indices",
"version": "0.16.6",
"version": "0.17.0",
"description": "Miscellaneous indices for graphology.",

@@ -5,0 +5,0 @@ "main": "index.js",

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