# graph

[flow_graph.graph]

Class that serves as a handle to a flow graph of nodes and edges.

    // Defined in header <oneapi/tbb/flow_graph.h>

    namespace oneapi {
    namespace tbb {
    namespace flow {

        class graph {
        public:
            graph();
            graph(task_group_context& context);
            ~graph();

            void wait_for_all();

            void reset(reset_flags f = rf_reset_protocol);
            void cancel();
            bool is_cancelled();
            bool exception_thrown();
        };

    } // namespace flow
    } // namespace tbb
    } // namespace oneapi

## reset_flags enumeration

- reset_flags Enumeration

## Member functions

graph(task_group_context &context)

  Constructs a graph with no nodes. If `context` is specified, the graph tasks are executed in this context. By default, the graph is executed in a bound context of its own.

~graph()

  Calls `wait_for_all()` on the graph, then destroys the graph.

void wait_for_all()

  Blocks execution until all tasks associated with the graph have completed or cancelled.

void reset(reset_flags f = rf_reset_protocol)

  Resets the graph according to the specified flags. Flags to `reset()` can be combined with bitwise-`or`.

  Note

  `reset()` is a thread-unsafe operation, don’t call it concurrently.

void cancel()

  Cancels all tasks in the graph.

bool is_cancelled()

  Returns: `true` if the graph was cancelled during the last call to `wait_for_all()`; `false`, otherwise.

bool exception_thrown()

  Returns: `true` if during the last call to `wait_for_all()` an exception was thrown; `false`, otherwise.