graphs-adt
Version:
Graph data structure with path finding and traversing algorithms
31 lines • 844 B
TypeScript
interface Result {
distance: number;
previous: string | null;
}
declare class Node {
key: string;
neighbours: Node[];
constructor(key: string);
addNeighbour(node: Node): void;
}
export declare class Graph {
private nodes;
private edges;
private directed;
constructor({ directed }?: {
directed?: boolean;
});
addNode(key: string): void;
getNode(key: string): Node;
addEdge(key1: string, key2: string, weight: number): void;
getEdge(key1: string, key2: string): number | undefined;
private findLowest;
dijkstra(source: string): {
[key: string]: Result;
};
getPath(source: string, destination: string): string[];
bfs(startKey: string, fn: Function): void;
dfs(startKey: string, fn: Function): void;
}
export {};
//# sourceMappingURL=graph.d.ts.map