maths.ts
Version:
Math utilities library for TypeScript, JavaScript and Node.js
78 lines (77 loc) • 2.53 kB
TypeScript
/**
* @author Hector J. Vasquez <ipi.vasquez@gmail.com>
*
* @licence
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Edge from './Edge';
/**
* Represents a vertex of a graph. It must provide an id and a neighborhood,
* that is, a list of adjacent vertexes. Vertexes may be built manually or
* with the Graph class for its internal handling.
*/
export default class Vertex {
id: number;
private _name;
info: any;
/**
* Builds a vertex with an optional name and optional extra information
* for it.
* @param id The id of this vertex on graph. Must be handled internally
* by the Graph which this vertex belongs to.
* @param _name The name this is going to get when printing.
* @param info
*/
constructor(id: number, _name?: string, info?: any);
/**
* @property id Must be handled internally by the Graph which this vertex
* belongs to.
*/
private _edges;
/**
* Returns the list of edges adjacent to this.
* @return The edges of this vertex.
*/
readonly edges: Edge[];
/**
* The name for this vertex, if there is.
* @return The name of this vertex.
*/
/**
* Sets a name for this graph.
* @param value The new name for this.
*/
name: string;
/**
* Adds an edge to this vertex neighborhood.
* @param e The new edge from this.
*/
addEdge(e: Edge): void;
/**
* Returns the neighborhood of this vertex, that is, the vertexes
* connected to this with an edge.
* @return A list of the vertexes connected to this vertex through an edge.
*/
getNeighborHood(): Vertex[];
/**
* Checks if another vertex is equivalent to this.
* @param v The other vertex.
* @return true if this equals v, false otherwise.
*/
equals(v: Vertex): boolean;
/**
* Gets useful information about this vertex.
* @return The name of this and the edges associated to this vertex.
*/
toString(): string;
}