Skip to content

@graphty/graphty-element / session / SetsApi

Interface: SetsApi ​

Defined in: graphty-element/src/session/sets/types.ts:182

Kept sets: the reads that only look at records and the writes that resolve nothing. Every write is one operation (set.create, set.rename, set.redefine, set.members, set.remove) and a no-op records and emits nothing.

Methods ​

addMembers() ​

addMembers(id, members): void

Defined in: graphty-element/src/session/sets/types.ts:349

Add members to a fixed set.

Parameters ​

id ​

string

The set.

members ​

The nodes and edges to add.

edges? ​

readonly EdgeRef[]

The edges, by session id or stable identity.

nodes? ​

readonly NodeId[]

The node ids.

Returns ​

void


combine() ​

combine(op, of, options?): Promise<string>

Defined in: graphty-element/src/session/sets/types.ts:325

Combine two or more sets into one fixed set of their current members, created from combine. difference is the first minus the union of the rest; symmetric-difference keeps what an odd number of them hold. Every operand read induced gives an induced result; otherwise edges are combined first and the result keeps their endpoints, so "edges in the Kruskal tree but not the Prim tree" keeps the differing edges and the nodes they join. An empty result is kept.

Parameters ​

op ​

SetCombine

The combination.

of ​

readonly ScopeInput[]

Two or more scopes.

options? ​

How to keep it.

name? ​

string

The name; "Set N" when absent.

reading? ​

EdgeReading

The reading to store instead of the default.

Returns ​

Promise<string>

The minted id.


containing() ​

containing(element): Promise<Memberships>

Defined in: graphty-element/src/session/sets/types.ts:246

What holds one element: the kept sets, and the partition items of every finished run. A cached resolution is tested when present; else a fixed set of nodes alone is a binary search of them, and a rule whose leaves are all element-local is tested at this element. Anything else is resolved once and cached.

Parameters ​

element ​

{ node: NodeId; } | { edge: string; }

The node or edge.

Type Literal ​

{ node: NodeId; }

The node or edge.

node ​

NodeId

A node id.


Type Literal ​

{ edge: string; }

The node or edge.

edge ​

string

A session edge id.

Returns ​

Promise<Memberships>

The memberships.

Throws ​

E_BAD_COMMAND for an element the graph does not hold.


create() ​

create(definition, options?): string

Defined in: graphty-element/src/session/sets/types.ts:256

Keep a definition as given; created from user. Edge members may be given as session edge ids and are stored in stable form.

Parameters ​

definition ​

SetDefinitionInput

The definition.

options? ​

How to keep it.

name? ​

string

The name; "Set N" (the smallest free N) when absent. At most 256 characters, because the id is minted from it.

Returns ​

string

The minted id.


createFrom() ​

createFrom(source, options?): Promise<string>

Defined in: graphty-element/src/session/sets/types.ts:290

Create set: keep a scope's current members as a fixed set, created from selection or from the scope. Resolves first, then mints the id and names the set in one step, so two calls in flight never share an id: the second with a taken name is refused E_DUPLICATE_ID.

The reading, unless options.reading says otherwise: a selection holding nodes keeps the selected nodes and edges and reads induced; a selection of edges alone reads listed; any other scope keeps the reading it resolves with, and clipped (such as "visible") freezes to listed, which holds the same members. A defaulted listed result whose edges are exactly those its nodes induce is stored induced with no edges, so it GAINS an edge added later between two of its members; an explicit listed never does. "largest-component" stores its nodes alone.

An offer keeps its own reading and is created from result, holding its execution. With follow, it is kept instead as a rule over the item without the execution, so it follows the run's re-runs; a partition group cannot be followed, because a group number means nothing in another run.

The members are read when the asynchronous step resolves the source, not when the call is made: a set the source names that is redefined synchronously after this call is frozen as redefined. Await the call before changing what it reads to freeze the membership as it was.

Parameters ​

source ​

ScopeInput | SetOffer

The scope; "selection" for the current selection with its edges; or an offer.

options? ​

How to keep it.

follow? ​

boolean

Keep an offer as a rule that follows its run.

name? ​

string

The name; "Set N" (the smallest free N) when absent.

reading? ​

EdgeReading

The reading to store instead of the default.

Returns ​

Promise<string>

The minted id.

Throws ​

E_SCOPE_EMPTY when the source holds nothing; E_BAD_COMMAND for a malformed scope, an unknown set or a bad reading; E_DUPLICATE_ID for a taken name; E_BAD_COMMAND with details.reason: "stale-offer" for an offer whose execution is no longer its run's current one, checked before resolving and again at commit, and "follow-group" for following a partition group.


createPath() ​

createPath(source, options?): Promise<string>

Defined in: graphty-element/src/session/sets/types.ts:310

Create path: order the selected edges into a walk, created from selection. Parallel and reciprocal edges between one pair become one step. The walk starts at the end from which every step follows a declared edge direction when only one end allows that, else at the end whose id sorts first. One selected node and no edges is a zero-length path.

A path offer is kept in its result's order, each step naming the on-path edges between its pair, created from result; a stale one is refused as createFrom refuses it.

Parameters ​

source ​

"selection" | SetOffer

"selection", or a path offer.

options? ​

How to keep it.

name? ​

string

The name; "Set N" when absent.

Returns ​

Promise<string>

The minted id.

Throws ​

E_BAD_COMMAND with details.reason: "ambiguous-path" and details.why (no-edges, self-loop, branch, cycle, disconnected, off-path-nodes) when the selection is not one open chain.


get() ​

get(id): ElementSet | undefined

Defined in: graphty-element/src/session/sets/types.ts:193

One kept set.

Parameters ​

id ​

string

Its id.

Returns ​

ElementSet | undefined

The record, or undefined when no live set has that id.


list() ​

list(): readonly ElementSet[]

Defined in: graphty-element/src/session/sets/types.ts:187

Every kept set, by order, ties by id. The same frozen objects until a record changes.

Returns ​

readonly ElementSet[]

The sets.


offers() ​

offers(run, options?): object

Defined in: graphty-element/src/session/sets/types.ts:226

The sets a finished run's result offers, largest first, from its shape: one per group of a partition (a components run's first is the largest component), one per level, one per category, one for a node or edge set, one for a path. Metrics, temporal results and candidate pairs offer none. Never resolves and never runs the edge-count pass.

Parameters ​

run ​

string

The run.

options? ​

How many to return.

limit? ​

number

The most offers returned; 100 by default.

Returns ​

The largest limit offers and how many were left out.

more ​

readonly more: number

How many offers were left out.

offers ​

readonly offers: readonly SetOffer[]

The largest limit offers, largest first.

Throws ​

E_UNKNOWN_RUN for a run this session does not hold; E_BAD_COMMAND for a limit that is not a whole number of at least 0.


pathKind() ​

pathKind(id): PathKind | undefined

Defined in: graphty-element/src/session/sets/types.ts:207

A path set's kind. Derived from its definition; never resolves.

Parameters ​

id ​

string

The set.

Returns ​

PathKind | undefined

The kind, or undefined for a set that is not a path or not live.


redefine() ​

redefine(id, definition): void

Defined in: graphty-element/src/session/sets/types.ts:341

Replace a set's definition.

Parameters ​

id ​

string

The set.

definition ​

SetDefinitionInput

The new definition.

Returns ​

void


remove() ​

remove(id): void

Defined in: graphty-element/src/session/sets/types.ts:369

Remove the set itself. Anything that names it becomes detached, and keeps working: a style layer, filter or rule that names a removed set reads it from the set's kept record, so removing a set never blanks a layer or changes what a filter shows. New work over a removed set -- a run, an explicit layout scope -- is refused. The record is kept while anything names the set, and dropped once nothing does.

Parameters ​

id ​

string

The set.

Returns ​

void


removeMembers() ​

removeMembers(id, members): void

Defined in: graphty-element/src/session/sets/types.ts:357

Remove members from a fixed set. Removing a node also removes its incident edge members.

Parameters ​

id ​

string

The set.

members ​

The nodes and edges to remove.

edges? ​

readonly EdgeRef[]

The edges, by session id or stable identity.

nodes? ​

readonly NodeId[]

The node ids.

Returns ​

void


rename() ​

rename(id, name): void

Defined in: graphty-element/src/session/sets/types.ts:335

Rename a set. Keeps its id and its revision.

Parameters ​

id ​

string

The set.

name ​

string

The new name, trimmed; unique among live sets.

Returns ​

void


restore() ​

restore(id): void

Defined in: graphty-element/src/session/sets/types.ts:378

Bring a removed set back from its kept record, under the same id, name and definition. Tells one set:changed with change "created".

Parameters ​

id ​

string

The removed set.

Returns ​

void

Throws ​

E_BAD_COMMAND when the id names a live set (details.reason: "live"), was never issued ("unknown-id"), or its record was dropped because nothing named it any more ("record-dropped").


status() ​

status(ref): SetStatus

Defined in: graphty-element/src/session/sets/types.ts:201

Whether a set, or any scope, still means what it meant: from what it reads and the last pass over it. Never resolves, so a panel may call it for every row.

Parameters ​

ref ​

ScopeInput

The set, as { set: id }, or any scope.

Returns ​

SetStatus

The status.

Throws ​

E_BAD_COMMAND for a malformed scope or an id that was never issued.


usedBy() ​

usedBy(id): readonly SetUser[]

Defined in: graphty-element/src/session/sets/types.ts:213

What names a set: the kept sets whose definitions name it and the runs whose scope names it.

Parameters ​

id ​

string

The set.

Returns ​

readonly SetUser[]

The users, sets first, each group in listing order.