# Flow Graph

[flow_graph]

In addition to loop parallelism, the oneAPI Threading Building Blocks (oneTBB) library also supports graph parallelism. With this feature, highly scalable and completely sequential graphs can be created.

There are three types of components used to implement a graph:

- A `graph` class instance

- Nodes

- Ports and edges

## Graph Class

The `graph` class instance owns all the tasks created on behalf of the flow graph. Users can wait on the `graph` if they need to wait for the completion of all of the tasks related to the flow graph execution. Users can also register external interactions with the `graph` and run tasks under the ownership of the flow graph.

- graph
  - reset_flags Enumeration

## Nodes

### Abstract Interfaces

To be used as a graph node type, a class needs to inherit certain abstract types and implement the corresponding interfaces. `graph_node` is the base class for any other node type; its interfaces always have to be implemented. If a node sends messages to other nodes, it has to implement the `sender` interface, while with the `receiver` interface the node may accept messages. For nodes that have multiple inputs and/or outputs, each input port is a `receiver` and each output port is a `sender`.

- graph_node
- sender
- receiver

### Properties

Every node in a flow graph has its own properties.

- Forwarding and Buffering

### Functional Nodes

Functional nodes do computations in response to input messages (if any), and send the result or a signal to their successors.

- continue_node
- function_node
- input_node
- multifunction_node
- async_node

Auxiliary

- Function Nodes Policies
- Nodes Priorities
- Predefined Concurrency Limits
- copy_body

### Buffering Nodes

Buffering nodes are designed to accumulate input messages and pass them to successors in a predefined order, depending on the node type.

- overwrite_node
- write_once_node
- buffer_node
- queue_node
- priority_queue_node
- sequencer_node

### Service Nodes

These nodes are designed for advanced control of the message flow, such as combining messages from different paths in a graph or limiting the number of simultaneously processed messages, as well as for creating reusable custom nodes.

- limiter_node
- broadcast_node
- join_node
  - join_node Policies
- split_node
- indexer_node
- composite_node

## Ports and Edges

Flow Graph provides an API to manage connections between the nodes. For nodes that have more than one input or output ports (for example, `join_node`), making a connection requires to specify a certain port by using special helper functions.

- input_port
- output_port
- make_edge
- remove_edge

## Special Messages Types

Flow Graph supports a set of specific message types.

- continue_msg
- tagged_msg

## Examples

- Dependency Flow Graph Example
- Message Flow Graph Example