The class with functionality for the base graph type.

Type Parameters

Hierarchy (view full)

Accessors

Methods

  • Changes the functionality class of the current graph. This is only possible if the data and scratch data are compatible with the new class. To assert that, use BaseGraph.Class.is.

    Type Parameters

    Parameters

    • GraphType: {
          Class: Graph.Class<D, S, G>;
      }

      The graph type to change the functionality class into.

    Returns G

    The same graph, wrapped in the new functionality class.

  • Changes the functionality class of the current graph. Should only be used when it is known (but not statically provable) that the graph is compatible with the new class. If not, an error will be thrown.

    It is bad practice to try and catch the error thrown by this function. For such cases, combine BaseGraph.Class.is with BaseGraph.Class.as, or use BaseGraph.Class.switch instead.

    Type Parameters

    Parameters

    • GraphType: Graph<D2, S2, G2>

      The graph type to change the functionality class into.

    • Optionalmessage: string

      The message to throw if the graph is not compatible with the type.

    Returns G2

    The graph, wrapped in the new functionality class.

    LaraFlowError if the graph is not compatible with the type. This error should be seen as a logic error and not catched.

  • Initializes the graph with the information of a builder. This is effectively extends the type of the graph to include the data and scratch data of the builder.

    The same graph may simultaneously be of multiple types, as long as the data and scratch data are compatible with the types. The builder methods may overwrite data and scratch data fields with names that collide with its type's fields.

    Type Parameters

    Parameters

    Returns BaseGraph.Class<D2, S2>

    The same graph, with the data and scratch data of the builder. The graph is downcasted to BaseGraph.Class because the builder may overwrite the data and scratch data fields, invalidating the current type.

  • Sets the id generator to be used when generating edge identifiers. This id generator is only used when creating an edge without specifying an id. In other words, if an id is explicitly provided when creating an edge, it will have precedence over calling the id generator.

    When no id generator is set and no id is provided when creating an edge, the id generation will be delegated to cytoscape.

    Parameters

    • generator: undefined | Edge.IdGenerator

      The id generator to use, or undefined to delegate to cytoscape's default id generation.

    Returns this

    itself for chaining.

  • Sets the id generator to be used when generating node identifiers. This id generator is only used when creating a node without specifying an id. In other words, if an id is explicitly provided when creating a node, it will have precedence over calling the id generator.

    When no id generator is set and no id is provided when creating a node, the id generation will be delegated to cytoscape.

    Parameters

    • generator: undefined | Node.IdGenerator

      The id generator to use, or undefined to delegate to cytoscape's default id generation.

    Returns this

    itself for chaining.

  • Tries to change the functionality class of the current graph. If the graph is not compatible with the new class, undefined is returned.

    Type Parameters

    Parameters

    • GraphType: Graph<D2, S2, G2>

      The graph type to change the functionality class into.

    Returns undefined | G2

    The graph, wrapped in the new functionality class, or undefined if the graph is not compatible with the type.

    if (graph === undefined || !graph.is(FlowGraph)) {
    return undefined;
    }
    return node.as(FlowGraph);

    Can be simplified to:

    return node?.tryAs(FlowGraph);