Type Parameters

Hierarchy

  • Class<D, S>
    • Class

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

    A collection of all edges in the graph.

  • get functions(): NodeCollection<Class<Data, ScratchData>, Data, ScratchData>
  • Retrieves all functions in the graph.

    The functions must be in the map, the respective nodes must exist, and the nodes must be FunctionNode to be included in the collection.

    Returns NodeCollection<Class<Data, ScratchData>, Data, ScratchData>

    A collection of all functions in the graph.

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

    A collection of all nodes in the 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 Graph.scratchNamespace | @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: Class<Data, ScratchData>

      The source node of the edge.

    • target: Class<Data, ScratchData>

      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 Class<Data, ScratchData>

    the newly created edge.

  • Adds a FunctionNode to the graph, updating the function map.

    Parameters

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

    • Optionalnode: Class<Data, ScratchData>

      The node to initialize as the FunctionNode. If not provided, a new node will be created.

    Returns Class<Data, ScratchData>

    The FunctionNode that was added.

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

  • Parameters

    • fn: FunctionJp
    • Optionalnode: Class<Data, ScratchData>

    Returns ClavaFunctionNode.Class<ClavaFunctionNode.Data, ClavaFunctionNode.ScratchData>

  • Adds a new empty node to the graph.

    Parameters

    • Optionalid: string

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

    • Optionalparent: Class<Data, ScratchData>

      The parent node of the node to add. If not provided, the node will be orphan.

    Returns Class<Data, ScratchData>

    the newly created node.

  • Applies a Graph.Transformation to the graph. May be chained.

    Type Parameters

    • G2 extends Class<Data, ScratchData>

    Parameters

    Returns G2

    The graph after applying the transformation.

  • Creates a collection from an array of nodes. Given that the array may be empty, passing the NodeType is mandatory.

    Type Parameters

    • D extends Data
    • S extends ScratchData
    • N extends Class<D, S>

    Parameters

    • NodeType: Node<D, S, N>

      The type of node to create a collection for.

    • nodes: N[]

      The nodes to create a collection from.

    Returns NodeCollection<N, D, S>

    A collection of the given type with the given nodes.

  • Creates a collection from an array of edges. Given that the array may be empty, passing the EdgeType is mandatory.

    Type Parameters

    • D extends Data
    • S extends ScratchData
    • E extends Class<D, S>

    Parameters

    • EdgeType: Edge<D, S, E>

      The type of edge to create a collection for.

    • edges: E[]

      The edges to create a collection from.

    Returns EdgeCollection<E, D, S>

    A collection of the given type with the given edges.

  • 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

    • G extends Class<D, S>

    Parameters

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

      The graph type to change the functionality class into.

      • Class: Class<D, S, G>

    Returns G

    The same graph, wrapped in the new functionality class.

  • Type Parameters

    • N extends Class<D, S>
    • D extends Data
    • S extends ScratchData

    Parameters

    • NodeType: Node<D, S, N>

      The type of node to create an empty collection for.

    Returns NodeCollection<N, D, S>

    An empty collection of the given type.

  • Type Parameters

    • D extends Data
    • S extends ScratchData
    • E extends Class<D, S>

    Parameters

    • EdgeType: Edge<D, S, E>

      The type of edge to create an empty collection for.

    Returns EdgeCollection<E, D, S>

    An empty collection of the given type.

  • 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

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

    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.

  • Retrieve a specific edge from the graph by its id.

    Parameters

    • id: string

      The id of the edge to get.

    Returns undefined | Class<Data, ScratchData>

    The edge with the given id, or undefined if no such edge exists.

  • Retrieve a specific node from the graph by its id.

    Parameters

    • id: string

      The id of the node to get.

    Returns undefined | Class<Data, ScratchData>

    The node with the given id, or undefined if no such node exists.

  • 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

    • D2 extends Data
    • S2 extends ScratchData

    Parameters

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

      The builder to use to initialize the graph.

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

  • Checks if this graph'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
    • G2 extends Class<D2, S2>

    Parameters

    • GraphType: Graph<D2, S2, G2>

      The graph type to check compatibility with.

    Returns this is Class<D2, S2>

    Whether the graph is compatible with the given 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 | 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 | IdGenerator

      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

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

    • formatter: Formatter<ClavaFlowGraph.Class<D, S>>

      The formatter to use.

    • filename: string

      The name of the file to write to.

    Returns void

    The file to where the contents where written.

  • Converts the graph to a string using a Graph.Formatter.

    Parameters

    Returns string

    The string representation of the graph.

  • 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

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

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