SPeCS Packages Documentation
    Preparing search index...

    The class with functionality for the base graph type.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    • get data(): D

      Use the data object for JSON serializable data. For temporary or non-serializable data, use BaseGraph.Class.scratchData.

      Returns D

      the data object associated with this graph.

    • get scratchData(): S

      Use the scratch data object for temporary or non-serializable data. For JSON serializable data, use BaseGraph.Class.data.

      The scratch data is stored under the @specs-feup/flow namespace.

      Returns S

      the scratch data object associated with this graph.

    Methods

    • Adds a new empty edge to the graph, connecting two existing nodes.

      Parameters

      • source: BaseNode.Class

        The source node of the edge.

      • target: BaseNode.Class

        The target node of the edge.

      • Optionalid: string

        The id of the edge to add. If not provided, a new id will be generated.

      Returns BaseEdge.Class

      the newly created edge.

    • 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.

    • Checks if the graph has a function with the given name.

      The function must be in the map, the respective node must exist, and the node must be a FunctionNode for this method to return true.

      Parameters

      • name: string

        The name of the function.

      Returns boolean

      true if the graph has a function with the given name, false otherwise.

    • Parameters

      Returns boolean

    • 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: Edge.IdGenerator | undefined

        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: Node.IdGenerator | undefined

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

      Returns this

      itself for chaining.

    • Checks if the type of the graph is compatible with several types, calling a callback for the first match. See Graph.Case for the syntax of each case.

      For a default case, match with BaseGraph, which will always be compatible with any graph type.

      Parameters

      • ...cases: { callback: (g: any) => void; GraphType: Graph<any, any, any> }[]

        The cases to match against.

      Returns void

    • Returns Core

      the underlying cytoscape graph object.

    • Converts the graph to a string using a Graph.Formatter and writes it to a file.

      Parameters

      Returns void

      The file to where the contents where written.

    • 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 G2 | undefined

      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);