Type Parameters

Hierarchy

  • Class<D, S>
    • Class

Accessors

  • get adjacentEdges(): EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges that are adjacent to this node.

  • get adjacentNodes(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The nodes that are adjacent to this node.

  • get ancestors(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The ancestors (parents, parents' parents, etc.) of this node.

  • get cfgEntryNode(): undefined | Class<Data, ScratchData>
  • Returns undefined | Class<Data, ScratchData>

    The initial node of the function's CFG. This is the entry point of the function.

  • set cfgEntryNode(node): void
  • Sets the initial node of the function's CFG. This is the entry point of the function.

    Parameters

    • node: undefined | Class<Data, ScratchData>

      The new entry node.

    Returns void

  • get children(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The children of this node.

  • get controlFlowNodes(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The control flow nodes that belong to this function.

  • 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 descendants(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The descendants (children, children's children, etc.) of this node.

  • get functionName(): string
  • Returns string

    The name of the function. This name must be unique in the graph, so it should be mangled if the use case permits overloading.

  • get graph(): Class<Data, ScratchData>
  • Returns Class<Data, ScratchData>

    the graph that this node is a part of.

  • get id(): string
  • Returns string

    the unique identifier of this node.

  • get incomers(): EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges that connect to 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 outgoers(): EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges that connect from this node.

  • get parent(): undefined | Class<Data, ScratchData>
  • Returns undefined | Class<Data, ScratchData>

    the parent node of this node.

  • set parent(node): void
  • Changes the parent node of this node.

    Parameters

    • node: undefined | Class<Data, ScratchData>

      The new parent node. If undefined, the node becomes orphan.

    Returns void

  • get predecessors(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The predecessors of this node. This repeatedly follows the sources of incoming 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.

  • get successors(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The successors of this node. This repeatedly follows the targets of outgoing edges.

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

    • N2 extends Class<D, S>

    Parameters

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

      The node type to change the functionality class into.

      • Class: Class<D, S, N2>

    Returns N2

    The same node, wrapped in the new functionality class.

  • Parameters

    • Optionalpropagate: ((edge: Class<Data, ScratchData>) => boolean)
        • (edge): boolean
        • Parameters

          • edge: Class<Data, ScratchData>

          Returns boolean

    Returns Generator<SearchVisit, any, any>

  • Parameters

    • Optionalpropagate: ((edge: Class<Data, ScratchData>) => boolean)
        • (edge): boolean
        • Parameters

          • edge: Class<Data, ScratchData>

          Returns boolean

    Returns Generator<SearchVisit, any, any>

  • Retrieves the edges from the given nodes to this node.

    Parameters

    • nodes: Class<Data, ScratchData> | NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

      The node or collection of nodes to check for edges connected with this node.

    Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges from the given nodes to this node.

  • Retrieves the edges from this node to the given nodes.

    Parameters

    • nodes: Class<Data, ScratchData> | NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

      The node or collection of nodes to check for edges connected with this node.

    Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges from this node to the given nodes.

  • Retrieves the edges that connect this node with the given nodes. Direction is not considered.

    Parameters

    • nodes: Class<Data, ScratchData> | NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

      The node or collection of nodes to check for edges connected with this node.

    Returns EdgeCollection<Class<Data, ScratchData>, Data, ScratchData>

    The edges that connect this node with the given nodes.

  • 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

    • D2 extends Data
    • S2 extends ScratchData
    • N2 extends Class<D2, S2>

    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

    • D2 extends Data
    • S2 extends ScratchData

    Parameters

    • builder: Builder<D2, S2, D, S>

      The builder to use to initialize the node.

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

  • Checks if this node's data and scratch data are compatible with a specific type. This is effectively a type guard function.

    Type Parameters

    • D2 extends Data
    • S2 extends ScratchData
    • N2 extends Class<D2, S2>

    Parameters

    • NodeType: Node<D2, S2, N2>

      The node type to check compatibility with.

    Returns this is Class<D2, S2>

    Whether the node is compatible with the given type.

  • Returns boolean

    Whether this function is registered in the graph.

    LaraFlowError if the node is not part of a FlowGraph.

  • Registers the function in the graph, so that its name points to this node.

    Returns void

    LaraFlowError if the node is not part of a FlowGraph or if another function with the same name is already registered in the graph.

  • Removes this node from the graph.

    Returns void

  • Changes the function name. This name must be unique in the graph, so it should be mangled if the use case permits overloading.

    The graph's function map will be updated.

    Parameters

    • name: string

      The new name of the function.

    Returns this

    Itself, for chaining.

    LaraFlowError if the new function name already exists in the graph. This should be seen as a logic error and should not be catched. Instead, ensure that no existing function shares the same name by renaming or removing.

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

    Returns void

  • Type Parameters

    • V extends SearchVisit

    Parameters

    Returns Generator<V, any, any>

  • 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

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

      The cases to match against.

    Returns void

  • Returns NodeCollection<ClavaFunctionNode.Class<D, S>, D, S>

    A collection containing only this node.

  • 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

    • D2 extends Data
    • S2 extends ScratchData
    • N2 extends Class<D2, S2>

    Parameters

    • NodeType: Node<D2, S2, N2>

      The node type to change the functionality class into.

    Returns undefined | N2

    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);
    
  • Unregisters the function from the graph, removing its name from the function map.

    Returns void

    LaraFlowError if the node is not part of a FlowGraph.