/** * @template [T=string] The type of nodes in the graph * * A generic graph implementation with edge weights. * * Edge weights are assumed to be non-negative numbers (including `Infinity`) */ export class GenericGraph { /** * Returns a shallow copy of the `Set` of nodes in the graph. */ get nodes(): Set; /** * Adds a node to the graph. * If node was already added, this function does nothing. * If node was not already added, this function sets up an empty adjacency list. * @param {T} node Node to add * @returns {this} This graph instance */ addNode(node: T): this; /** * Removes a node from the graph. * Also removes incoming and outgoing edges. * @param {T} node * @returns {this} */ removeNode(node: T): this; /** * Gets the adjacent nodes set for the given node. * @param {T} node * @returns {Set|undefined} */ adjacent(node: T): Set | undefined; /** * Sets the weight of the given edge between `source` and `target`. * * @param {T} source Source node * @param {T} target Target node * @param {number} weight New edge weight * @returns {this} */ setEdgeWeight(source: T, target: T, weight: number): this; /** * Gets the weight of the given edge between `source` and `target`. * * @param {T} source Source node * @param {T} target Target node * @returns {number} Edge weight from source to target */ getEdgeWeight(source: T, target: T): number; /** * Adds an edge from the `source` node to `target` node. * * This method will create the `source` and `target` node(s) if they do not * already exist. * * If {@link T `T`} is an object, the comparison is by-reference. * * @param {T} source Source node * @param {T} target Target node * @param {number} weight Edge weight from source to target * @returns {this} This graph instance */ addEdge(source: T, target: T, weight: number): this; /** * Removes the edge from the `source` node to `target` node. * Does not remove the nodes themselves. * Does nothing if the edge does not exist. * @param {T} source * @param {T} target * @returns {this} */ removeEdge(source: T, target: T): this; /** * Returns true if there is an edge from the `source` node to `target` node. * @param {T} source * @param {T} target * @returns {boolean} */ hasEdge(source: T, target: T): boolean; #private; } export function makeShortestPath(graph: GenericGraph): (source: NoInfer, target: NoInfer) => [T, T, ...T[]]; //# sourceMappingURL=generic-graph.d.ts.map