traffic-traversal
Version:
Calculate the weights between each vertex node and help you find the fastest route.
60 lines (59 loc) • 2.83 kB
TypeScript
import type { ITrafficGraphState, GraphVertex } from './TrafficGraph';
export declare class TrafficTraversal {
private readonly _trafficGraph;
private readonly _cEdge;
private readonly _cStrings;
private readonly _cNumber;
private readonly _cNumbers;
private readonly _cVertex;
static Create(...args: ConstructorParameters<typeof TrafficTraversal>): TrafficTraversal;
/**
* Create an instance that is responsible for the route and utility functions of the graph instance. It takes a `graph.state` instance as a parameter.
* @param trafficGraphState
*/
constructor(trafficGraphState: ITrafficGraphState);
protected _graphVertex(vertex: string): GraphVertex;
private _getTrafficPrev;
protected _getRoutes(from: string, to: string): string[];
protected _reach(routes: string[], from: string, to: string): boolean;
/**
* Finds the route with the lowest weight between two vertices and returns it as an array.
* @param from This is the starting vertex.
* @param to This is the target vertex.
*/
routes(from: string, to: string): string[];
private _addEdges;
/**
* Returns a list of vertices adjacent to that vertex as an array. You can set a depth limit using the `depth` parameter.
* This means that the vertex at the back of the array is deeper.
* @param vertex The vertex from which to start the search.
* @param depth Set how deep to search from the vertex. If you specify this value as a negative number, the search is unrestricted. Default is `-1`.
*/
edges(vertex: string, depth?: number): string[];
/**
* Returns whether the target vertex can be reached from the starting vertex.
* @param from This is the starting vertex.
* @param to This is the target vertex.
*/
reachable(from: string, to: string): boolean;
/**
* Returns the sum of the least weighted routes from the starting vertex to the target vertex.
* @param from This is the starting vertex.
* @param to This is the target vertex.
*/
traffic(from: string, to: string): number;
weight(vertex: string, mode: 'traffic' | 'number' | 'mean'): number;
/**
* Returns the shortest distance from the starting vertex to the target vertex. This is similar to the `distance` method, but takes direction into account. If unreachable, returns `Infinity`.
* @param from This is the starting vertex.
* @param to This is the target vertex.
* @returns
*/
depth(from: string, to: string): number;
/**
* Returns the shortest distance between two vertices. This is similar to the `depth` method, but does not take direction into account.
* @param a The vertex a.
* @param b The vertex b.
*/
distance(a: string, b: string): number;
}