transform.shortcut
shortcut(config: ShortcutConfig, options?: ShortcutOptions): Promise<TransformResult>Replace a set of intermediate ("through") nodes with direct edges between their neighbours. Intermediate nodes are removed and shortcut edges are created between each pair of neighbours that previously connected through a removed node.
The operation is recorded in history as "ShortcutNodes" and is fully undoable.
config | ShortcutConfig | through: category of intermediate nodes to remove;
incomingRelationship: only treat edges where B is the TARGET as A-side connections;
outgoingRelationship: only treat edges where B is the SOURCE as C-side connections. |
options | ShortcutOptions | Optional: newRelationship names the shortcut edges (default: incomingRelationship or "SHORTCUT");
countPaths writes the number of shared intermediates onto the shortcut edge property countProperty;
sourceCategory/targetCategory restrict which neighbours qualify; aggregate applies
formula aggregations from intermediate node properties onto the shortcut edge. |
Returns: Promise<TransformResult>
Example
// Remove Tag nodes and connect their neighbours directly
await api.transform.shortcut({ through: "Tag" }, { newRelationship: "SHARES_TAG", countPaths: true });