Interface Connect<NodeDatum, Ops>

an operator that constructs a MutGraph from link data.

Create a default connect operator with graphConnect. The accessor for the source id string, target id string, and whether to allow single nodes can all be modified.

Links in the dag will have the same data as the objects passed in, and nodes will have the ids referenced as either the source or the target.

interface Connect<NodeDatum, Ops extends ConnectOps<NodeDatum>> {
    nodeDatum<
        NewNodeDatum,
        NewNodeDatumOp extends IdNodeDatum<NewNodeDatum>,
    >(
        data: NewNodeDatumOp & IdNodeDatum<NewNodeDatum>,
    ): Connect<NewNodeDatum, U<Ops, "nodeDatum", NewNodeDatumOp>>;
    nodeDatum(): Ops["nodeDatum"];
    single(val: boolean): Connect<NodeDatum, Ops>;
    single(): boolean;
    sourceId<NewId extends Id<never>>(
        id: NewId,
    ): Connect<NodeDatum, U<Ops, "sourceId", NewId>>;
    sourceId(): Ops["sourceId"];
    targetId<NewId extends Id<never>>(
        id: NewId,
    ): Connect<NodeDatum, U<Ops, "targetId", NewId>>;
    targetId(): Ops["targetId"];
    <L extends unknown>(data: readonly L[]): MutGraph<NodeDatum, L>;
}

Type Parameters

Methods

  • set the single node allowance

    Sets the allowance for single nodes. If enabled and the source id equals the target id, then a single node with no parents will be created. Otherwise a self loop will be created which will result in an error. Note only single nodes without parents or children need to be specified this way, otherwise any other connection to a node will create it.

    (default: false)

    Parameters

    • val: boolean

    Returns Connect<NodeDatum, Ops>

  • get the current single node setting.

    Returns boolean