export type GraphVertexCalc = Record; export type GraphVertex = Record; export type TrafficGraphData = { vertex: Record; embedded: string[]; }; export interface ITrafficGraphState { readonly data: Readonly; readonly vertices: Readonly; readonly timestamp: number; } export declare class TrafficGraph { /** * It is an object that contains weight information between the vertex of the graph. */ private readonly _data; /** * Create a new graph instance. You can generate from existing data using `data` parameters. * @param data You can restore it with existing data.This data can be obtained by `TrafficGraph.data`. */ constructor(data?: TrafficGraphData); static Create(...args: ConstructorParameters): TrafficGraph; /** * Returns to an array in the form that can serialize the graph information of the current instance. */ get data(): TrafficGraphData; /** * The current status of the instance is exported to an immutable object. */ get state(): Readonly; /** * Returns all the vertices listed in the current instance in an array. */ get vertices(): string[]; /** * Currently copied instance and returns to a new instance. */ get clone(): TrafficGraph; private _graphVertex; private _embed; private _calculate; /** * Create a single direction weight route. It is possible to traverse the `source` to `dest`, but vice versa is impossible. * If you had the same vertex before, the value is overwritten. * @param source The starting vertex. * @param dest This is a list of weights of each vertex. You can specify relative values. If you fill in the prior character `+=`, `-=`, `*=`, `/=`, The target value is calculated based on the current value of the property. * @example * graph.to('a', { b: 1 }) * graph.to('a', { b: '+=1' }) */ to(source: string, dest: GraphVertex | GraphVertexCalc): this; /** * Set the weight route that leads to both directions between the two vertices. 'a' vertex and 'b' vertex can traverse to each other. * For example, `graph.both('a', { b: 1 })` is same as `graph.to('a', { b: 1 }).to('b', { a: 1 })` * @param a The vertex a. * @param b This is a list of weights of each vertex. You can specify relative values. If you fill in the prior character `+=`, `-=`, `*=`, `/=`, The target value is calculated based on the current value of the property. * @example * graph.both('a', { b: 1 }) * graph.both('a', { b: '+=1' }) */ both(a: string, b: GraphVertex | GraphVertexCalc): this; /** * Set the weight between all vertices passed by parameters. * For example, `graph.all({ a: 1, b: 2, c: 3 })` is same as `graph.to('a', { b: 2, c: 3 }).to('b', { a: 1, c: 3 }).to('c', { a: 1, b: 2 })` * @param dest This is a list of weights of each vertex. You can specify relative values. If you fill in the prior character `+=`, `-=`, `*=`, `/=`, The target value is calculated based on the current value of the property. * @example * graph.all({ a: 1, b: 2, c: 3 }) * graph.all({ a: '+=1', b: '+=1', c: '+=1' }) */ all(dest: GraphVertex | GraphVertexCalc): this; /** * Delete the single direction weight route created by the `to` method. * @param source The starting vertex. * @param dest The target vertex. */ unlinkTo(source: string, dest: string): this; /** * Delete the bidirectional weight route created by the `both` method. * @param a The vertex a. * @param b The vertex b. */ unlinkBoth(a: string, b: string): this; /** * Delete certain vertices. All weight routes connected to the vertex are deleted. * @param vertex The vertex what you want to delete. */ drop(vertex: string): this; /** * It returns whether the instance has a vertex. * @param vertex The vertex what you want to check. */ has(vertex: string): boolean; /** * It returns whether all the vertices exist in that instance. Returns `false` if any of the vertices are missing. * @param vertices The vertices what you want to check. */ hasAll(...vertices: string[]): boolean; /** * Invert all weights in an instance. For example, when A to B has a `2` weight, it will be `-2`. * It's useful for switching the shortest to longest routes or minimum to maximum traffic in a graph. * @example * const inverted = TrafficTraversal.Create(traffic.invert().state) * const longest = invertedTraversal.routes('A', 'B') */ invert(): this; }