Convert Graph, Vertex, and Edge into interfaces
This commit is contained in:
parent
db7889d843
commit
5d82a2f043
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue