UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

32 lines 1.09 kB
import { Graph } from "../../core/graph.js"; import type { NodeId, TraversalOptions, TraversalResult } from "../../types/index.js"; /** * Depth-First Search (DFS) implementation * * Explores graph by going as deep as possible before backtracking. * Useful for cycle detection, topological sorting, and connectivity analysis. */ /** * DFS traversal options */ export interface DFSOptions extends TraversalOptions { recursive?: boolean; preOrder?: boolean; } /** * Perform depth-first search starting from a given node */ export declare function depthFirstSearch(graph: Graph, startNode: NodeId, options?: DFSOptions): TraversalResult; /** * Detect cycles in a graph using DFS */ export declare function hasCycleDFS(graph: Graph): boolean; /** * Topological sorting using DFS (for directed acyclic graphs) */ export declare function topologicalSort(graph: Graph): NodeId[] | null; /** * Find strongly connected components using DFS (for directed graphs) */ export declare function findStronglyConnectedComponents(graph: Graph): NodeId[][]; //# sourceMappingURL=dfs.d.ts.map