UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

62 lines 2.2 kB
import type { Graph } from "../core/graph.js"; import type { NodeId } from "../types/index.js"; import { CSRGraph, type ReadonlyGraph } from "./csr-graph.js"; /** * Adapter to convert standard Graph to CSR format * * Provides transparent conversion while maintaining API compatibility */ export declare class GraphAdapter<TNodeId = NodeId> implements ReadonlyGraph<TNodeId> { private csrGraph; constructor(graph: Graph | ReadonlyGraph<TNodeId>); /** * Convert standard graph to CSR format */ private convertToCSR; nodeCount(): number; edgeCount(): number; hasNode(nodeId: TNodeId): boolean; hasEdge(source: TNodeId, target: TNodeId): boolean; neighbors(nodeId: TNodeId): IterableIterator<TNodeId>; outDegree(nodeId: TNodeId): number; nodes(): IterableIterator<TNodeId>; /** * Get the underlying CSR graph */ getCSRGraph(): CSRGraph<TNodeId>; } /** * Configuration for graph algorithm optimizations */ export interface GraphAlgorithmConfig { useDirectionOptimizedBFS?: boolean; useCSRFormat?: boolean; useBitPackedStructures?: boolean; bfsAlpha?: number; bfsBeta?: number; preallocateSize?: number; enableCaching?: boolean; } /** * Configure optimizations globally * @deprecated This function is a no-op and will be removed in a future version */ export declare function configureOptimizations(_config: GraphAlgorithmConfig): void; /** * Get current configuration * @deprecated This function returns empty config and will be removed in a future version */ export declare function getOptimizationConfig(): GraphAlgorithmConfig; /** * Check if a graph is already in CSR format */ export declare function isCSRGraph<TNodeId = NodeId>(graph: unknown): graph is CSRGraph<TNodeId>; /** * Convert any graph to CSR format */ export declare function toCSRGraph<TNodeId = NodeId>(graph: Graph | ReadonlyGraph<TNodeId> | CSRGraph<TNodeId>): CSRGraph<TNodeId>; /** * Create an optimized graph from nodes and edges */ export declare function createOptimizedGraph<TNodeId = NodeId>(nodes: TNodeId[], edges: [TNodeId, TNodeId, number?][]): CSRGraph<TNodeId>; //# sourceMappingURL=graph-adapter.d.ts.map