/** * Weighted directed graph parameterized by a semiring. * * The graph represents the agent network. Nodes are motebits. * Edges carry semiring-valued weights (trust, cost, latency, or products thereof). * * Key insight: the same graph structure supports different queries by * swapping the semiring used in traversal. The graph stores raw edge data; * the semiring determines how to compose and compare paths. */ import type { Semiring } from "./semiring.js"; export interface Edge { readonly from: string; readonly to: string; readonly weight: T; } /** * Immutable-ish weighted digraph. Nodes are string IDs (motebit_id). * Edges are stored adjacency-list style for efficient traversal. */ export declare class WeightedDigraph { private readonly semiring; private readonly _adj; private readonly _nodes; constructor(semiring: Semiring); /** The semiring this graph operates over. */ get sr(): Semiring; addNode(id: string): void; /** * Set an edge weight. If the edge already exists, the new weight * is ⊕-combined with the existing weight (parallel edges merge). */ addEdge(from: string, to: string, weight: T): void; /** Set an edge weight, replacing any existing weight. */ setEdge(from: string, to: string, weight: T): void; removeEdge(from: string, to: string): void; removeNode(id: string): void; hasNode(id: string): boolean; hasEdge(from: string, to: string): boolean; /** Get edge weight, or semiring zero if no edge exists. */ getEdge(from: string, to: string): T; nodes(): ReadonlySet; nodeCount(): number; /** Outgoing edges from a node. */ neighbors(id: string): ReadonlyMap; /** All edges in the graph. */ edges(): Edge[]; edgeCount(): number; } //# sourceMappingURL=graph.d.ts.map