brainy/.recovery-workspace/dist-backup-20250910-141917/graph/pathfinding.d.ts
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

78 lines
2.1 KiB
TypeScript

/**
* Advanced Graph Pathfinding Algorithms
* Provides shortest path, multi-hop traversal, and path ranking
*/
export interface GraphNode {
id: string;
[key: string]: any;
}
export interface GraphEdge {
source: string;
target: string;
type: string;
weight: number;
metadata?: any;
}
export interface Path {
nodes: string[];
edges: GraphEdge[];
totalWeight: number;
length: number;
}
export interface PathfindingOptions {
maxDepth?: number;
maxPaths?: number;
bidirectional?: boolean;
weightField?: string;
relationshipTypes?: string[];
nodeFilter?: (node: GraphNode) => boolean;
edgeFilter?: (edge: GraphEdge) => boolean;
}
export declare class GraphPathfinding {
private adjacencyList;
private nodes;
/**
* Add a node to the graph
*/
addNode(node: GraphNode): void;
/**
* Add an edge to the graph
*/
addEdge(edge: GraphEdge): void;
/**
* Find shortest path using Dijkstra's algorithm
* O((V + E) log V) with binary heap
*/
shortestPath(start: string, end: string, options?: PathfindingOptions): Path | null;
/**
* Find all paths between two nodes
* Uses DFS with cycle detection
*/
allPaths(start: string, end: string, options?: PathfindingOptions): Path[];
/**
* Bidirectional search for faster pathfinding
* Searches from both start and end simultaneously
*/
bidirectionalSearch(start: string, end: string, options?: PathfindingOptions): Path | null;
/**
* Multi-hop traversal (e.g., friends of friends)
* Returns all nodes within N hops
*/
multiHopTraversal(start: string, hops: number, options?: PathfindingOptions): Map<string, {
distance: number;
paths: Path[];
}>;
/**
* Find connected components using DFS
*/
connectedComponents(): Array<Set<string>>;
/**
* Calculate PageRank for all nodes
* Useful for ranking importance in the graph
*/
pageRank(iterations?: number, damping?: number): Map<string, number>;
/**
* Clear the graph
*/
clear(): void;
}