/** * Finds all [connected components][] in a graph and returns an array of these * components. Each component is itself an array that contains the ids of nodes * in the component. * * [connected components]: http://en.wikipedia.org/wiki/Connected_component_(graph_theory) * * @example * * ![](https://github.com/dagrejs/graphlib/wiki/images/components.png) * * ```js * graphlib.alg.components(g); * // => [ [ 'A', 'B', 'C', 'D' ], * // [ 'E', 'F', 'G' ], * // [ 'H', 'I' ] ] * ``` * * @param {Graph} g - The graph to find components in. * @returns {NodeID[][]} An array of components, each of which is an array of node IDs. * * @remarks This function takes `O(|V|)` time. */ export function components(g: Graph): NodeID[][]; import type { Graph } from '../graph.js'; import type { NodeID } from '../graph.js';