typescript-generic-datastructures
Version:
21 lines (20 loc) • 1.02 kB
TypeScript
import { GraphVertex } from './GraphVertex';
import { GraphEdge } from './GraphEdge';
export declare class Graph<TVertex, TEdge> {
isDirected: boolean;
vertices: Record<string | number, GraphVertex<TVertex, TEdge>>;
edges: Record<string, GraphEdge<TVertex, TEdge>>;
constructor(isDirected?: boolean);
addVertex(newVertex: GraphVertex<TVertex, TEdge>): this;
getVertexByKey(vertexKey: string | number): GraphVertex<TVertex, TEdge>;
getNeighbors(vertex: GraphVertex<TVertex, TEdge>): GraphVertex<TVertex, TEdge>[];
getAllVertices(): GraphVertex<TVertex, TEdge>[];
getAllEdges(): GraphEdge<TVertex, TEdge>[];
addEdge(edge: GraphEdge<TVertex, TEdge>): this;
deleteEdge(edge: GraphEdge<TVertex, TEdge>): void;
findEdge(startVertex: GraphVertex<TVertex, TEdge>, endVertex: GraphVertex<TVertex, TEdge>): GraphEdge<TVertex, TEdge> | null;
reverse(): this;
getVerticesIndices(): Record<string | number, number>;
getAdjacencyMatrix(): any[][];
toString(): string;
}