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

flex-algo

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flex-algo - npm Package Compare versions

Comparing version 0.1.19 to 0.1.20

4

lib/graph.d.ts
declare class Graph {
_adjList: number[][];
_indegrees: number[];
_nodes: number;
constructor();
create(vectors: number[][], nodes: number): void;
createInformTimeGraph(manager: number[], nodes: number): void;
createCourseGraph(courses: number[][], numCourses: number): void;
_dfsInformTime(vertex: number, informTime: number[]): number;

@@ -12,3 +15,4 @@ informTime(headID: number, informTime: number[]): number;

bfs(vertex: number): number[];
isAcyclic(): boolean;
}
export { Graph };

@@ -7,2 +7,4 @@ "use strict";

this._adjList = [];
this._indegrees = [];
this._nodes = 0;
}

@@ -26,2 +28,14 @@ Graph.prototype.create = function (vectors, nodes) {

};
Graph.prototype.createCourseGraph = function (courses, numCourses) {
this._nodes = numCourses;
this._adjList = new Array(numCourses).fill(0).map(function () { return []; });
this._indegrees = new Array(numCourses).fill(0);
for (var i = 0; i < courses.length; i++) {
var vector = courses[i];
var target = vector[0];
var source = vector[1];
this._adjList[source].push(target);
this._indegrees[target] += 1;
}
};
Graph.prototype._dfsInformTime = function (vertex, informTime) {

@@ -85,4 +99,29 @@ var neighbors = this._adjList[vertex];

};
Graph.prototype.isAcyclic = function () {
var queue = [];
for (var i = 0; i < this._indegrees.length; i++) {
if (this._indegrees[i] === 0) {
queue.push(i);
}
}
var count = 0;
while (queue.length > 0) {
var vertex = queue.shift();
count += 1;
if (vertex === undefined) {
continue;
}
var neighbors = this._adjList[vertex];
for (var i = 0; i < neighbors.length; i++) {
var neighbor = neighbors[i];
this._indegrees[neighbor] -= 1;
if (this._indegrees[neighbor] === 0) {
queue.push(neighbor);
}
}
}
return count === this._nodes;
};
return Graph;
}());
exports.Graph = Graph;

2

package.json
{
"name": "flex-algo",
"version": "0.1.19",
"version": "0.1.20",
"description": "\"SDK for commonly used data structure and algorithms\"",

@@ -5,0 +5,0 @@ "main": "lib/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