The chain from `start` down to the holder, following `prev` links.
(
start: string,
parent: Map<string, { prev: string | null; edge: Edge | null }>,
nodes: Map<string, Node>
)
| 634 | |
| 635 | /** The chain from `start` down to the holder, following `prev` links. */ |
| 636 | function pathFrom( |
| 637 | start: string, |
| 638 | parent: Map<string, { prev: string | null; edge: Edge | null }>, |
| 639 | nodes: Map<string, Node> |
| 640 | ): Array<{ node: Node; edge: Edge | null }> { |
| 641 | const out: Array<{ node: Node; edge: Edge | null }> = []; |
| 642 | let id: string | null = start; |
| 643 | let edgeInto: Edge | null = null; |
| 644 | while (id !== null) { |
| 645 | const node = nodes.get(id)!; |
| 646 | out.push({ node, edge: edgeInto }); |
| 647 | const step: { prev: string | null; edge: Edge | null } = parent.get(id)!; |
| 648 | edgeInto = step.edge; |
| 649 | id = step.prev; |
| 650 | } |
| 651 | return out; |
| 652 | } |
| 653 | |
| 654 | // ============================================================================= |
| 655 | // Conditions |