Skip to content

Nodes, edges and terminals

A node represents a position in a process: for example, choosing an option or reaching a result. An edge is a directed connection from one node to another. When your application chooses an edge and the engine accepts it, the session moves from the edge’s source node to its destination.

A graph also identifies where execution starts and where it can finish. Its root is the node at which new sessions begin. Its terminal nodes are explicitly marked endpoints. Understanding those roles lets you tell where a session is and whether it has finished.

Read the structure and the current position

Section titled “Read the structure and the current position”

We will use the workshop graph introduced in Graph-based execution model. It offers online attendance or in-person attendance with a venue choice. Here, the session has already chosen the in-person route and is waiting at the venue-selection step.

Annotated workshop graph: node 100 is the root, node 200 is the session's current position, edge 201 leads from it to terminal 300, and the online route leads to terminal 400.

The graph contains four nodes. Nodes 100 and 200 are steps from which the session can continue. Nodes 300 and 400 are terminals: reaching either completes this selection process.

Each arrow represents a separate edge. Edge 101 connects node 100 to node 200; edge 201 connects node 200 to terminal 300. To select Valencia from the current position, your application requests edge 201. The destination node is part of that edge’s definition.

The direction matters. Defining an edge from 100 to 200 allows that move; it does not also create a return route.

The root belongs to the graph; the current node belongs to a session

Section titled “The root belongs to the graph; the current node belongs to a session”

The graph declares its root explicitly through rootNodeId. In this example, it is node 100. The engine does not infer the root from the lowest ID or from the order in which the nodes were declared. The root must be a non-terminal node.

When a new session starts, its current node is the root. After it follows edge 101, its current node becomes 200, while the graph’s root remains 100. Another session using the same graph can still be at the root or already be at a terminal.

This is why the current-position marker in a graph view describes the session you are inspecting. Moving that marker does not change the graph’s starting point.

A node is terminal because the graph declares it with isTerminal: true. Terminal nodes have no outgoing edges. Once the session reaches one, there is no further edge to choose from that position.

A terminal can also provide outputs, such as a message or a link for your application to present. Those outputs are optional: a terminal with no outputs still completes the route. Terminal outputs explains how to add and use them.

Having no usable choice at a particular moment means something different. The workshop session can be at node 200 while the Valencia edge is blocked because there are no places available. That session has not reached a terminal.

Situation What it means
The session is at node 300 or 400, declared terminal. The route is complete, whether or not the terminal provides outputs.
The session is at node 200, but its Valencia edge is blocked. The session remains at a non-terminal node and cannot make that choice with the current data.
A non-terminal node has no outgoing edges defined at all. The graph definition is invalid; this is not a way to declare an endpoint.

Your application should therefore identify completion from the terminal result, rather than infer it from an empty list of usable options.

IDs identify elements independently of their text

Section titled “IDs identify elements independently of their text”

Nodes and edges each have integer IDs. Node IDs must be unique among the graph’s nodes, and edge IDs must be unique among its edges. The edge’s source and destination refer to node IDs; the session’s current position also refers to a node ID.

These references let your application identify an element without relying on the wording shown on screen. Changing “In person” to “Attend in person” does not require changing the edge’s ID. When your application requests a move, it sends the edge ID, not its visible label or the destination node ID.

Open Graph basics to inspect these roles in an interactive graph. If the demo opens in Spanish, select EN in its header. Its root is node 10. Follow edge 101 and watch the current position move to node 20; the root stays at 10. Then follow edge 201 to terminal 90.

The demo’s terminals have no outputs configured. You can still see that navigation has finished: completion comes from reaching the terminal node.