SPeCS Packages Documentation
    Preparing search index...

    The class with functionality for the base node 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 BaseNode.Class.scratchData.

      Returns D

      the data object associated with this node.

    • get degree(): number

      Returns the number of edges connected to this node. Loop edges are counted twice.

      Returns number

      the degree of this node.

    • get degreeWithoutLoops(): number

      Returns the number of edges connected to this node. Loop edges are not counted.

      Returns number

      the degree of this node, excluding loop edges.

    • get graph(): BaseGraph.Class

      Returns BaseGraph.Class

      the graph that this node is a part of.

    • get id(): string

      Returns string

      the unique identifier of this node.

    • get indegree(): number

      Returns the number of edges that are directed towards this node.

      Returns number

      the indegree of this node.

    • get indegreeWithoutLoops(): number

      Returns the number of edges that are directed towards this node. Loop edges are not counted.

      Returns number

      the indegree of this node, excluding loop edges.

    • get isChild(): boolean

      Returns boolean

      whether this node is a child node.

    • get isParent(): boolean

      Returns boolean

      whether this node is a parent node.

    • get isRemoved(): boolean

      Returns boolean

      whether this node has been removed from the graph.

    • get outdegree(): number

      Returns the number of edges that are directed away from this node.

      Returns number

      the outdegree of this node.

    • get outdegreeWithoutLoops(): number

      Returns the number of edges that are directed away from this node. Loop edges are not counted.

      Returns number

      the outdegree of this node, excluding loop edges.

    • get scratchData(): S

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

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

      Returns S

      the scratch data object associated with this node.

    Methods

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

      Type Parameters

      Parameters

      • NodeType: { Class: Node.Class<D, S, N2> }

        The node type to change the functionality class into.

      Returns N2

      The same node, wrapped in the new functionality class.

    • Changes the functionality class of the current node. Should only be used when it is known (but not statically provable) that the node 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 BaseNode.Class.is with BaseNode.Class.as, or use BaseNode.Class.switch instead.

      Type Parameters

      Parameters

      • NodeType: Node<D2, S2, N2>

        The node type to change the functionality class into.

      • Optionalmessage: string

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

      Returns N2

      The node, wrapped in the new functionality class.

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

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

      The same node 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 BaseNode.Class<D2, S2>

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

    • Removes this node from the graph.

      Returns void

    • Restores this node if it has been removed. See BaseNode.Class.remove.

      Returns void

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

      For a default case, match with BaseNode, which will always be compatible with any node type.

      Parameters

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

        The cases to match against.

      Returns void

    • Returns NodeSingular

      the underlying cytoscape node object.

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

      Type Parameters

      Parameters

      • NodeType: Node<D2, S2, N2>

        The node type to change the functionality class into.

      Returns N2 | undefined

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

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

      Can be simplified to:

      return node?.tryAs(ControlFlowNode);