UNPKG

lgrthms

Version:

Algorithms and data structures for your JavaScript and TypeScript projects 🧑‍💻

26 lines (25 loc) 829 B
declare class Node<T = any> { id: string; value: T; edges: Record<string, number>; constructor(id: string, value: T); } export declare class Graph<T = any> { private readonly DEFAULT_WEIGHT; private _nextId; private _size; private readonly _graph; constructor(); get size(): number; getNode(id: number | string): Node<T> | undefined; getEdges(id: number | string): { neighborId: string; weight: number; }[]; addNode(value: T, id?: number | string): Node<T>; addEdge(nodeId: number | string, neighborId: number | string, weight?: number): void; removeNode(id: number | string): void; removeEdge(nodeId: number | string, neighborId: number | string): void; adjacent(nodeId: number | string, neighborId: number | string): boolean; } export {};