Use the data object for JSON serializable data. For temporary or non-serializable data, use BaseGraph.Class.scratchData.
the data object associated with this graph.
A collection of all edges in the graph.
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.
A collection of all functions in the graph.
A collection of all nodes in the graph.
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.
the scratch data object associated with this graph.
Adds a FunctionNode to the graph, updating the function map.
The name of the function. This name must be unique in the graph, so it should be mangled if the use case permits overloading.
Optional
node: BaseNode.Class<BaseNode.Data, BaseNode.ScratchData>The node to initialize as the FunctionNode. If not provided, a new node will be created.
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.
Applies a Graph.Transformation to the graph. May be chained.
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.
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.
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.
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.
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.
The id of the edge to get.
The edge with the given id, or undefined if no such edge exists.
Retrieves a FunctionNode from the graph by the name of the function.
If the function is not in the map, the node does not exist, or the node
is not a FunctionNode, undefined
will be returned.
The name of the function.
The FunctionNode, or undefined
if it does not exist.
Retrieve a specific node from the graph by its id.
The id of the node to get.
The node with the given id, or undefined if no such node exists.
Retrieves a FunctionNode from the graph by the name of the function. If the function does not exist, a new node will be created, updating the function map.
The name of the function.
The FunctionNode that was retrieved or created.
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
.
The name of the function.
true
if the graph has a function with the given name, false
otherwise.
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.
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.
The id generator to use, or undefined to delegate to cytoscape's default id generation.
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.
The id generator to use, or undefined to delegate to cytoscape's default id generation.
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.
Rest
...cases: _Case<BaseGraph.Data, BaseGraph.ScratchData, BaseGraph.Class<BaseGraph.Data, BaseGraph.ScratchData>>[]The cases to match against.
Converts the graph to a string using a Graph.Formatter.
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.
The graph, wrapped in the new functionality class, or undefined if the graph is not compatible with the type.
The class with functionality for the base graph type.