See ConstructSiftingMatchDiagramResult.
const siftingMatch = await runSiftingPattern({ patternName: "mutiny" });
if (match) {
const diagram = await constructSiftingMatchDiagram({ siftingMatch, ansi: true });
console.log(diagram);
}
⋮ (31)
└─ insult-crew-member (buildup) [a1]
⋮ (4)
└─ recruit-conspirators (buildup) [a2]
⋮ (3)
[⋯a1] ⋮ (7)
─┼ ⋮ (14)
└─ attempt-mutiny (mutiny) [a3]
└─ captain-defeats-mutiny (mutiny) [a4]
└─ maroon-on-island (aftermath) [a5]
⋮ (74)
└─ signal-passing-ship (aftermath) [a6]
└─ board-ship (aftermath) [a7]
⋮ (512)
⋮ (8)
└─ cut-crew-rations (buildup) [b1]
⋮ (2)
└─ recruit-conspirators [=a2]
┌──────────────────────┐
│ a1 : aid-f8a3b2c7 │
│ a2 : aid-2d4e6f8a │
│ a3 : aid-k1l2m3n4 │
│ a4 : aid-u1v2w3x4 │
│ a5 : aid-e1f2a3b4 │
│ a6 : aid-4b6c8d0e │
│ a7 : aid-l4m5n6o7 │
│ b1 : aid-m9n0o1p2 │
└──────────────────────┘
VivNotInitializedError If Viv has not been initialized.
VivValidationError If the sifting match is empty or contains invalid action IDs.
Returns a sifting-match diagram that visualizes a match for a sifting pattern.
The diagram constructed here is a causal tree diagram similar to what constructTreeDiagram returns, except in this case all the actions matched by the sifting pattern will be named nodes, whereas in a constructTreeDiagram only a single anchor action is named. Moreover, the diagram will include all ancestors, descendants, and collateral relatives for each of the actions matched by the pattern. As a result, sifting-match diagrams cover more ground, and thus by default make heavy use of elision, where entire subtrees are collapsed using elision indicators of the form
⋮ (N).The position of each elision indicator tells you what has been collapsed:
Nancestors of the root.Nintermediate actions on the direct causal path between them.N-1descendants.Ndescendants of the leaf.When a matched action has causal ancestors arriving via a separate lineage (from the one marked by the edge from its parent), a convergence indicator appears above it:
[⋯shortID] ⋮ (N):Nancestors arrive from the lineage of a named ancestor visible elsewhere in the diagram.─┼ ⋮ (N):Nancestors arrive from a lineage with no named ancestor in the diagram.Matched actions are labeled with their sifting-pattern role in parentheses, e.g.,
vow-revenge (turning-point) [a7]. In ANSI mode, each role gets a distinct color from a cycling palette.Finally, as in constructTreeDiagram, the diagram is technically a directed acyclic graph (DAG), may be presented with multiple distinct subtrees, and may make use of back references.