Socket
Socket
Sign inDemoInstall

@ralfderijcke/graph

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ralfderijcke/graph - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "@ralfderijcke/graph",
"version": "1.0.0",
"version": "1.0.1",
"description": "Basic graph data structure to store data",

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

# Graph
[![npm version](https://img.shields.io/npm/v/@ralfderijcke/graph)](https://www.npmjs.com/package/@ralfderijcke/graph)
Basic graph data structure to store data.
## Installation
[@ralfderijcke/graph](https://www.npmjs.com/package/@ralfderijcke/graph) is available as a npm.
```sh
npm install @ralfderijcke/graph --save
```
## Getting Started

@@ -17,2 +27,2 @@

const edge1 = graph.addEdge(vertex1, vertex2);
```
```
import { Edge } from "./edge";
import { Random } from "./random";
import { Vertex } from "./vertex";

@@ -29,10 +28,14 @@

// const nextEdge = targetEdges.find(e => !e.equals(edge)); // Not itself
// Take random edge
const nextEdges = targetEdges.filter(e => !e.equals(edge));
const nextEdges = targetEdges.filter(e => !e.equals(edge)); // Not itself
if (!nextEdges.length) {
return;
}
const n = Random.number(0, nextEdges.length);
console.log(n);
function randomNumber(min: number, max: number): number {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}
const n = randomNumber(0, nextEdges.length);
const nextEdge = nextEdges[n];

@@ -39,0 +42,0 @@

@@ -1,5 +0,3 @@

import { Random } from "./random";
export class Vertex {
public readonly graphKey: string = Random.string(8, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
public readonly graphKey: string = window.crypto.randomUUID();
public readonly value: object;

@@ -6,0 +4,0 @@

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