UNPKG

@barchart/common-js

Version:
70 lines (69 loc) 1.53 kB
/** * One node (vertex) of a directed graph data structure. * * @public */ export default class Vertex { /** * @param {*=} data */ constructor(data?: any | undefined); /** * Ad hoc data associated with the vertex (in other words the "value" * of the vertex). * * @public * @returns {*} */ public get data(): any; /** * Returns all edges from this vertex to other vertices. * * @public * @returns {Edge[]} */ public getEdges(): Edge[]; /** * Adds an edge. * * @public * @param {Vertex} other * @param {*=} data * @returns {Edge} */ public addEdge(other: Vertex, data?: any | undefined): Edge; /** * Locates an edge. * * @public * @param {Vertex} other * @returns {Edge|null} */ public getEdge(other: Vertex): Edge | null; /** * Indicates if this vertex has an edge. * * @public * @param {Vertex} other * @returns {boolean} */ public hasEdge(other: Vertex): boolean; /** * Finds all possible paths from this vertex (node) to another vertex (node). * * @public * @param {Vertex} other * @param {Edge[]=} walk * @returns {Edge[][]} */ public getPaths(other: Vertex, walk?: Edge[] | undefined): Edge[][]; /** * Returns a string representation. * * @public * @returns {string} */ public toString(): string; #private; } import Edge from './Edge.js';