@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
54 lines • 1.85 kB
TypeScript
import type { Graph } from "../../core/graph.js";
import type { NodeId } from "../../types/index.js";
/**
* BFS that tracks shortest path counts (for betweenness centrality)
*
* This variant of BFS computes:
* - Shortest distances from source to all reachable nodes
* - All predecessors on shortest paths
* - Number of shortest paths (sigma)
* - Stack of nodes in reverse BFS order
*/
export declare function bfsWithPathCounting(graph: Graph, source: NodeId, options?: {
optimized?: boolean;
}): {
distances: Map<NodeId, number>;
predecessors: Map<NodeId, NodeId[]>;
sigma: Map<NodeId, number>;
stack: NodeId[];
};
/**
* BFS that only returns distances (for closeness centrality)
*
* Optimized variant that skips predecessor tracking
*/
export declare function bfsDistancesOnly(graph: Graph, source: NodeId, cutoff?: number, options?: {
optimized?: boolean;
}): Map<NodeId, number>;
/**
* BFS for bipartite checking with partition sets
*
* Returns whether the graph is bipartite and the two partitions if it is
*/
export declare function bfsColoringWithPartitions(graph: Graph): {
isBipartite: boolean;
partitions?: [Set<NodeId>, Set<NodeId>];
};
/**
* BFS for finding augmenting paths (for flow algorithms)
*
* Finds a path from source to sink in a residual graph with positive capacity
*/
export declare function bfsAugmentingPath(residualGraph: Map<string, Map<string, number>>, source: string, sink: string): {
path: string[];
pathCapacity: number;
} | null;
/**
* BFS for weighted graphs using priority queue (simplified Dijkstra)
*
* Returns distances from source using edge weights
*/
export declare function bfsWeightedDistances(graph: Graph, source: NodeId, cutoff?: number, options?: {
optimized?: boolean;
}): Map<NodeId, number>;
//# sourceMappingURL=bfs-variants.d.ts.map