UNPKG

1.01 kBTypeScriptView Raw
1import { LinkList } from "../linklist/LinkList";
2import { GraphEdge } from "./GraphEdge";
3import { GraphVertex } from "./GraphVertex";
4export declare class Graph<T = string> {
5 private directed;
6 private vertices;
7 private edges;
8 constructor(directed?: boolean);
9 readonly Directed: boolean;
10 addVertex(vertex: GraphVertex<T>): this;
11 addEdgeByKey(start: string, end: string, weight?: number): this;
12 addEdge(start: GraphVertex<T>, end: GraphVertex<T>, weight?: number): this;
13 deleteEdge(start: GraphVertex<T>, end: string): boolean;
14 deleteEdgeByKey(start: string, end: string): boolean;
15 getVertexs(): GraphVertex<T>[];
16 getKeys(): string[];
17 getEdges(): GraphEdge<T>[];
18 findVertex(key: string): GraphVertex<T>;
19 findEdge(key: string): LinkList<GraphEdge<T>>;
20 deleteVertex(key: string): boolean;
21 toAdjacencyMatrix(): {
22 matrix: number[][];
23 keyIndexs: {
24 [index: string]: number;
25 };
26 };
27 clone(): Graph<T>;
28}