Convert Graph, Vertex, and Edge into interfaces

This commit is contained in:
Chegele 2023-07-06 15:44:38 -04:00
parent db7889d843
commit 5d82a2f043
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
export interface Graph {
vertices: Map<string, Vertex>;
edges: Map<string, Edge>;
getAllVertices(): Vertex[];
getVertex(id: string): Vertex;
addVertex(vertex: Vertex): void;
deleteVertex(vertex: string | Vertex): void;
getAllEdges(): Edge[];
getEdge(id: string): Edge;
addEdge(edge: Edge): void;
deleteEdge(edge: string | Edge): void;
}
export interface Vertex {
id: string;
edges: Edge[];
data: string;
}
export interface Edge {
id: string;
directional: boolean;
parentVertex: Vertex;
childVertex: Vertex;
getAdjacent(vertex: Vertex): Vertex;
}