data-structure-typed/src/interfaces/abstract-graph.ts

32 lines
895 B
TypeScript
Raw Normal View History

2023-10-10 19:55:52 +08:00
import {VertexKey} from '../types';
export interface IAbstractGraph<V, E> {
2023-10-10 19:55:52 +08:00
hasVertex(vertexOrKey: V | VertexKey): boolean;
2023-10-10 19:55:52 +08:00
addVertex(key: VertexKey, val?: V): boolean;
2023-10-10 19:55:52 +08:00
removeVertex(vertexOrKey: V | VertexKey): boolean;
2023-10-10 19:55:52 +08:00
removeAllVertices(vertices: V[] | VertexKey[]): boolean;
2023-10-10 19:55:52 +08:00
degreeOf(vertexOrKey: V | VertexKey): number;
2023-10-10 19:55:52 +08:00
edgesOf(vertexOrKey: V | VertexKey): E[];
2023-10-10 19:55:52 +08:00
hasEdge(src: V | VertexKey, dest: V | VertexKey): boolean;
2023-10-10 19:55:52 +08:00
getEdge(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
edgeSet(): E[];
2023-10-10 19:55:52 +08:00
addEdge(src: V | VertexKey, dest: V | VertexKey, weight: number, val: E): boolean;
removeEdge(edge: E): E | null;
2023-10-10 19:55:52 +08:00
setEdgeWeight(srcOrKey: V | VertexKey, destOrKey: V | VertexKey, weight: number): boolean;
2023-10-10 19:55:52 +08:00
getMinPathBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): V[] | null;
2023-10-10 19:55:52 +08:00
getNeighbors(vertexOrKey: V | VertexKey): V[];
}