dagre-d3-es
Version:
<p align="center"> <a href="https://tbo47.github.io/" ><img src="https://img.shields.io/badge/created_by-tbo47-blue.svg" alt="Created by tbo47"></a> <a href="https://www.npmjs.com/dagre-d3-es"><img src="https://img.shields.io/npm/v/dagre-d3-es.svg?log
32 lines (29 loc) • 894 B
JavaScript
import { dfs } from './dfs.js';
export { postorder };
/**
* This function performs a [postorder traversal][] of the graph `g` starting
* at the nodes `vs`. For each node visited, `v`, the function `callback(v)`
* is called.
*
* [postorder traversal]: https://en.wikipedia.org/wiki/Tree_traversal#Depth-first
*
* @example
*
* 
*
* ```js
* graphlib.alg.postorder(g, "A");
* // => One of:
* // [ "B", "D", "E", C", "A" ]
* // [ "B", "E", "D", C", "A" ]
* // [ "D", "E", "C", B", "A" ]
* // [ "E", "D", "C", B", "A" ]
* ```
*
* @param {Parameters<typeof dfs>[0]} g - The graph to traverse.
* @param {Parameters<typeof dfs>[1]} vs - Nodes to start the traversal from.
* @returns {ReturnType<typeof dfs>} The nodes in the order they were visited.
*/
function postorder(g, vs) {
return dfs(g, vs, 'post');
}