/** * A helper that preforms a pre- or post-order traversal on the input graph * and returns the nodes in the order they were visited. If the graph is * undirected then this algorithm will navigate using neighbors. If the graph * is directed then this algorithm will navigate using successors. * * @param {Graph} g - Input graph. * @param {NodeID[] | NodeID} vs - Starting node or array of nodes. * @param {'post' | 'pre'} order - The order to use. Must be one of "pre" or "post". * @returns {NodeID[]} The nodes in the order they were visited. */ export function dfs(g: Graph, vs: NodeID[] | NodeID, order: "post" | "pre"): NodeID[]; import type { Graph } from '../graph.js'; import type { NodeID } from '../graph.js';