Add BinaryHeap, Memo, and StateMachine, fixup previous caught bugs

This commit is contained in:
mindfulminun committed 2023-08-02 22:45:00 -05:00
1 parent fe9cc71154
commit 47b7cae5ed
10 files changed
+427 -304

No files matched your search

+5 -1
View File
@@ -1,6 +1,6 @@
import * as Colors from "https://deno.land/[email protected]/fmt/colors.ts"
type UUID = ReturnType<typeof crypto.randomUUID>
type UUID = string
export type VertexType<G> = G extends Graph<infer T, infer V> ? Vertex<T, V> : never
export type EdgeType<G> = G extends Graph<infer T, infer V> ? Edge<T, V> : never
@@ -166,6 +166,10 @@ export class Vertex<vData, eData> {
this.adjacentEdges = new Set()
}
/**
* Remove this vertex from the graph. Edges connected to this vertex will also be removed.
* Callers should discard this vertex after calling this method.
*/
delete() { this.graph.deleteVertex(this) }
toJSON(replacer: (this: Graph<vData, eData>, data: vData) => unknown = data => data) {