@agent-graph/core
Version:
A lightweight AI Agent orchestration solution
25 lines (24 loc) • 693 B
JavaScript
import { BuiltGraph } from './built-graph';
export class Graph {
constructor() {
this.vertices = new Map();
this.edges = new Map();
}
addV(vertex) {
if (this.vertices.has(vertex.id)) {
throw new Error(`Vertex ${vertex.id} already exists`);
}
this.vertices.set(vertex.id, vertex);
return this;
}
addE(from, to) {
if (this.edges.has(from.id)) {
throw new Error(`Edge from ${from.id} already exists`);
}
this.edges.set(from.id, to);
return this;
}
build({ context, checkpointer }) {
return new BuiltGraph({ builder: this, context, checkpointer });
}
}