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