Class ScriptGraph
java.lang.Object
com.soulfiremc.server.script.ScriptGraph
Represents the graph structure of a visual script.
Contains nodes and edges that define the execution flow and data connections.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructing ScriptGraph instances.static enumType of edge connection.static final recordRepresents an edge connecting two nodes.static final recordRepresents a node in the graph. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScriptGraph.BuilderCreates a new builder for constructing a ScriptGraph.edges()Finds all trigger nodes (entry points) in the graph.getIncomingDataEdges(String nodeId) Gets all incoming DATA edges for a node.getNextExecutionNodes(String nodeId, String outputHandle) Gets the next execution nodes from a given node's output handle.@Nullable ScriptGraph.GraphNodeGets a node by its ID.nodes()scriptId()Performs topological sort on the graph nodes.
-
Method Details
-
builder
Creates a new builder for constructing a ScriptGraph. -
getNode
Gets a node by its ID.- Parameters:
nodeId- the node identifier- Returns:
- the node, or null if not found
-
findTriggerNodes
-
getNextExecutionNodes
-
getIncomingDataEdges
Gets all incoming DATA edges for a node. Uses pre-computed map for O(1) lookup instead of scanning all edges.- Parameters:
nodeId- the target node ID- Returns:
- list of DATA edges targeting this node
-
topologicalSort
Performs topological sort on the graph nodes. Returns nodes in execution order, respecting dependencies.- Returns:
- list of node IDs in topological order
- Throws:
IllegalStateException- if the graph contains cycles
-
scriptId
-
scriptName
-
nodes
-
edges
-
outgoingEdgesByHandle
-
incomingEdgesByHandle
-
incomingDataEdgesByNode
-