> This page is for version 5.0.
> For other versions, use one of these documentation indexes:
> - 5.1 (Latest) (default): https://docs.nvidia.com/holoscan/sdk-user-guide/5-1-latest/llms.txt
> - ltsb-2.0: https://docs.nvidia.com/holoscan/sdk-user-guide/ltsb-2-0/llms.txt
> - 5.0: https://docs.nvidia.com/holoscan/sdk-user-guide/5-0/llms.txt
> - 4.6: https://docs.nvidia.com/holoscan/sdk-user-guide/4-6/llms.txt
> - 4.5: https://docs.nvidia.com/holoscan/sdk-user-guide/4-5/llms.txt
> - 4.4: https://docs.nvidia.com/holoscan/sdk-user-guide/4-4/llms.txt
> - 4.3: https://docs.nvidia.com/holoscan/sdk-user-guide/4-3/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sdk-user-guide/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.

# holoscan::Graph

> Own an editable cold graph declaration and replayable construction factories.

Own an editable cold graph declaration and replayable construction factories.

`Graph` is the only HSDK 5 root authoring abstraction. It performs lazy composition and cold validation but does not compile or execute a graph. The lazy-composition gate is internally synchronized, so concurrent observers share one composer and receive its terminal result. This synchronization does not make general authoring thread-safe: after composition, callers must serialize mutation with every other mutation or observation of the same `Graph`. Handles do not extend `Graph` lifetime and become invalid when the `Graph` is destroyed.

Every successful public compound mutation is atomic. If allocation or an injected exceptional boundary interrupts an in-progress mutation, `Graph` restores the prior snapshot identity, generation, IDs, ownership claims, and declaration indexes before the exception escapes. A rejected external topic declaration is the deliberate exception to counter rollback: ordinary typed validation failures consume their mixed import/export declaration ordinal, while exceptional failures restore the reserved ordinal.

```cpp showLineNumbers={false}
#include <holoscan/graph.hpp>
```

> **Warning**
>
> The complete most-derived `Graph` object must remain alive until all authoring, observation, and lazy-composition calls have returned. Destruction must not race any `Graph` access; handle invalidation does not provide concurrent destruction synchronization.

---

## Constructors

### Graph \[#graph]

#### Create an empty named \`Graph\` authoring root

```cpp showLineNumbers={false}
holoscan::Graph::Graph(
    std::string_view name = ""
)
```

Create an empty named `Graph` authoring root.

**Throws:** `RuntimeError` if `name` is invalid.

**Parameters**

**`name`** `std::string_view` — default: ""

Optional bounded UTF-8 name copied before return.

---

#### Deleted overloads

The following overloads are deleted to prevent misuse:

```cpp showLineNumbers={false}
holoscan::Graph::Graph(const Graph &) = delete;
holoscan::Graph::Graph(Graph &&) = delete;
```

### Destructor \[#destructor]

### \~Graph

```cpp showLineNumbers={false}
virtual holoscan::Graph::~Graph()
```

Destroy Graph-owned prototypes, factories, and authoring state.

> **Warning**
>
> Destruction must not overlap any authoring, observation, composition, or handle operation associated with this `Graph`.

---

## Assignment operators

### operator= \[#operator_assign]

#### Deleted overloads

The following overloads are deleted to prevent misuse:

```cpp showLineNumbers={false}
Graph & holoscan::Graph::operator=(const Graph &) = delete;
Graph & holoscan::Graph::operator=(Graph &&) = delete;
```

---

## Methods

### op \[#op]

```cpp showLineNumbers={false}
template <std::derived_from< OperatorBase > Op, typename... Args>
OperatorHandle<Op> holoscan::Graph::op(
    std::string_view name,
    Args &&... args
)
```

Add one typed [Operator](operator) declaration and replayable factory.

> **Note**
>
> If this is the first external authoring operation on a derived `Graph`, Core completes or terminally fails [`compose()`](#compose) before constructing the requested [Operator](operator) factory or prototype.

> **Note**
>
> Obvious top-level borrowed forms, move-only values, and `Graph` authoring handles are rejected at compile time. Function pointers and copyable callables are accepted. String views and string literals normalize to owned strings. Checks are intentionally shallow: nested container elements, user-defined fields, and callable captures remain the application's lifetime responsibility.

> **Warning**
>
> Do not call `Graph` authoring verbs from a derived `Graph` constructor; author the reusable body only in the Core-managed [compose](#compose) override.

> **Preconditions**
>
> Each normalized capture must be copy-constructible. Copies follow the captured type's ordinary C++ semantics, including shared identity for `std::shared_ptr` and non-owning observation for `std::weak_ptr`.

> **Preconditions**
>
> Any legacy [`Operator::start`](operatorbase#start) or [`Operator::stop`](operatorbase#stop) hook must be public, unambiguous, and have the exact zero-argument `void` signature. Any advanced lifecycle member callback registered by `setup()` must be declared by `Op` itself rather than by a base or unrelated class.

**Returns:** Copyable authoring handle that dynamically resolves current ports.

**Throws:** `RuntimeError` if construction, setup, naming, or registration fails.

**Template parameters**

**`Op`** `std::derived_from< OperatorBase >`

Concrete [Operator](operator) type.

---

**`Args`** `typename...`

Constructor capture argument types.

---

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 declaration name.

---

**`args`** `Args &&...`

Constructor values normalized and copied into replayable state.

---

### add_operator \[#addoperator]

```cpp showLineNumbers={false}
template <std::derived_from< OperatorBase > Op, typename... Args>
OperatorHandle<Op> holoscan::Graph::add_operator(
    std::string_view name,
    Args &&... args
)
```

Add one typed [Operator](operator) declaration using the exact [`op`](#op) alias.

**Returns:** Copyable typed authoring handle.

**Throws:** `RuntimeError` under the same conditions as [`op`](#op).

**Template parameters**

**`Op`** `std::derived_from< OperatorBase >`

Concrete [Operator](operator) type.

---

**`Args`** `typename...`

Constructor capture argument types.

---

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 declaration name.

---

**`args`** `Args &&...`

Constructor values copied under the same ownership precondition as [`op`](#op).

---

### handle \[#handle]

```cpp showLineNumbers={false}
template <std::derived_from< OperatorBase > Op>
OperatorHandle<Op> holoscan::Graph::handle(
    std::string_view name
)
```

Resolve one existing graph-local root [Operator](operator) by name and exact concrete type.

> **Note**
>
> This is a cold authoring-time lookup. It does not trigger lazy composition, inspect embedded `Graph` operators, or participate in per-activation execution.

> **Note**
>
> Whole-aggregate parameter reconstruction does not invalidate either the creation handle or a handle returned by this lookup.

**Returns:** Copyable typed authoring handle interchangeable with the creation handle.

**Throws:** `RuntimeError` with `GRAPH_OPERATOR_NOT_FOUND` when no root declaration has this name.

**Throws:** `RuntimeError` with `GRAPH_OPERATOR_TYPE_MISMATCH` when the named root declaration has another concrete [Operator](operator) type.

**Template parameters**

**`Op`** `std::derived_from< OperatorBase >`

Expected concrete [Operator](operator) type.

---

**Parameters**

**`name`** `std::string_view`

[Exact](../structs/exact) local declaration name from this `Graph`'s root authoring inventory.

---

### embed \[#embed]

```cpp showLineNumbers={false}
template <typename G, typename... Args>
GraphHandle<G> holoscan::Graph::embed(
    std::string_view instance_name,
    Args &&... args
)
```

Independently construct, compose, and own one reusable `Graph` instance.

> **Note**
>
> Child composition reaches a terminal state before one atomic parent publication. The child `Graph` is never copied or moved and remains owned by the parent until parent retirement.

> **Note**
>
> Unlike replayed [Operator](operator) and clock factories, embedding constructs the child once, so constructor arguments may transfer move-only ownership. The same shallow top-level borrow checks still apply, and `Graph` authoring handles remain rejected because they are composition-time identity.

> **Note**
>
> Embedded graphs do not inherit the parent's default clock. Declare clock dependencies in the child's [`compose()`](#compose) using [import_clock](#importclock), and use [set_default_clock](#setdefaultclock) when an imported clock is the child's default. After embedding, the immediate parent must supply each import using [bind_clock](#bindclock) before compilation. Nested reusable graphs require an explicit binding at every boundary; clock resolution never searches ancestor scopes by name.

> **Warning**
>
> The handle permits interface inspection only. It does not grant mutable access to the child authoring `Graph`.

**Returns:** Read-only typed handle exposing the child's public interface members.

**Throws:** `RuntimeError` if parent/child composition, construction, canonical remapping, name validation, or publication fails.

**Template parameters**

**`G`** `typename`

Concrete reusable `Graph` type.

---

**`Args`** `typename...`

Constructor capture argument types.

---

**Parameters**

**`instance_name`** `std::string_view`

Nonempty unique local embedded-instance name.

---

**`args`** `Args &&...`

Constructor values normalized and forwarded once into the child object.

---

**See also:**
[import_clock](#importclock),
[set_default_clock](#setdefaultclock),
[bind_clock](#bindclock)

### add_flow \[#addflow]

#### Overload 1

```cpp showLineNumbers={false}
template <PublishedPayload SourceT, PublishedPayload TargetT>
FlowHandle<SourceT, TargetT> holoscan::Graph::add_flow(
    const Output<SourceT> &source,
    const Input<TargetT> &target,
    ConnectionOptions options = {}
)
```

Add one exact-type or exact-contract raw-POD directed queue edge.

> **Note**
>
> Distinct C++ endpoint types participate only when both have explicit raw-POD contracts. Scalar, enum, [Tensor](tensor), and schema-root edges require the same C++ payload type.

**Returns:** Typed dynamic flow handle.

**Throws:** `RuntimeError` for foreign/stale ports, fan-in, cycles, duplicate topology, unequal complete POD contracts, or invalid options.

**Template parameters**

**`SourceT`** `PublishedPayload`

[Exact](../structs/exact) admitted source payload type.

---

**`TargetT`** `PublishedPayload`

[Exact](../structs/exact) admitted target payload type.

---

**Parameters**

**`source`** `const Output<SourceT> &`

Graph-owned output declaration.

---

**`target`** `const Input<TargetT> &`

Graph-owned input declaration.

---

**`options`** `ConnectionOptions` — default: \{}

Cold edge options copied before return.

---

#### Overload 2

```cpp showLineNumbers={false}
template <PublishedPayload SchemaT>
FlowHandle<SchemaT, Tensor> holoscan::Graph::add_flow(
    const ProjectedTensorOutput<SchemaT> &source,
    const Input<Tensor> &target,
    ConnectionOptions options = {}
)
```

Add one payload-narrowing edge from a named schema [Tensor](tensor) field to a [Tensor](tensor) input.

> **Note**
>
> Multiple [Tensor](tensor) and schema consumers may share an output. Same-process projection shares the selected data buffer until every consumer releases it. Inter-process delivery uses schema transport and requires bounded, copy-capable [Tensor](tensor) transfer contracts; staging may copy data when the backing cannot be shared. Projection does not convert representation. Runtime setup still allocates bookkeeping state. An explicit converter [Operator](operator) remains responsible for representation changes.

**Returns:** Typed dynamic flow handle.

**Throws:** `RuntimeError` for the same conditions as an exact-type edge, and when the consumer did not declare [InputSpecBuilder::accepts_projected_tensor](inputspecbuilder#acceptsprojectedtensor).

**Template parameters**

**`SchemaT`** `PublishedPayload`

Descriptor-backed schema published by the source [Operator](operator).

---

**Parameters**

**`source`** `const ProjectedTensorOutput<SchemaT> &`

[Tensor](tensor) field named on a Graph-owned schema output.

---

**`target`** `const Input<Tensor> &`

Graph-owned [Tensor](tensor) input that admits a projected [Tensor](tensor).

---

**`options`** `ConnectionOptions` — default: \{}

Cold edge options copied before return.

---

#### Overload 3

```cpp showLineNumbers={false}
template <PublishedPayload SchemaT>
FlowHandle<SchemaT, Tensor> holoscan::Graph::add_flow(
    const Output<SchemaT> &source,
    const Input<Tensor> &target,
    ConnectionOptions options = {}
)
```

Add one payload-narrowing edge from a single-Tensor schema output to a [Tensor](tensor) input.

> **Note**
>
> The field is unambiguous only when the schema carries exactly one [Tensor](tensor). A schema with several requires `.project()` so the `Graph` records which field was chosen.

**Returns:** Typed dynamic flow handle.

**Template parameters**

**`SchemaT`** `PublishedPayload`

Descriptor-backed schema carrying exactly one [Tensor](tensor) field.

---

**Parameters**

**`source`** `const Output<SchemaT> &`

Graph-owned schema output declaration.

---

**`target`** `const Input<Tensor> &`

Graph-owned [Tensor](tensor) input that admits a projected [Tensor](tensor).

---

**`options`** `ConnectionOptions` — default: \{}

Cold edge options copied before return.

---

#### Overload 4

```cpp showLineNumbers={false}
template <PublishedPayload T>
void holoscan::Graph::add_flow(
    const Input<T> &public_input,
    const Input<T> &internal_input
)
```

Bind a reusable `Graph` public input as an alias of an internal input.

> **Note**
>
> This is an interface alias, not a runtime queue edge, and therefore accepts no [ConnectionOptions](../structs/connectionoptions) and returns no [FlowHandle](flowhandle).

**Throws:** `RuntimeError` if either declaration belongs to another `Graph` or the payload/direction contract differs.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`public_input`** `const Input<T> &`

Stable public `Graph` input declaration.

---

**`internal_input`** `const Input<T> &`

Stable internal [Operator](operator) input declaration.

---

#### Overload 5

```cpp showLineNumbers={false}
template <PublishedPayload T>
void holoscan::Graph::add_flow(
    const Output<T> &internal_output,
    const Output<T> &public_output
)
```

Bind a reusable `Graph` public output as an alias of an internal output.

> **Note**
>
> This is an interface alias, not a runtime queue edge, and therefore accepts no [ConnectionOptions](../structs/connectionoptions) and returns no [FlowHandle](flowhandle).

**Throws:** `RuntimeError` if either declaration belongs to another `Graph` or the payload/direction contract differs.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`internal_output`** `const Output<T> &`

Stable internal [Operator](operator) output declaration.

---

**`public_output`** `const Output<T> &`

Stable public `Graph` output declaration.

---

### export_input \[#exportinput]

```cpp showLineNumbers={false}
template <PublishedPayload T>
void holoscan::Graph::export_input(
    const Input<T> &public_port,
    const Input<T> &internal_port
)
```

Expose an internal input through a reusable `Graph` input alias.

**Throws:** `RuntimeError` if alias validation fails.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`public_port`** `const Input<T> &`

Public `Graph` input declaration.

---

**`internal_port`** `const Input<T> &`

Internal [Operator](operator) input declaration.

---

### export_output \[#exportoutput]

```cpp showLineNumbers={false}
template <PublishedPayload T>
void holoscan::Graph::export_output(
    const Output<T> &public_port,
    const Output<T> &internal_port
)
```

Expose an internal output through a reusable `Graph` output alias.

**Throws:** `RuntimeError` if alias validation fails.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`public_port`** `const Output<T> &`

Public `Graph` output declaration.

---

**`internal_port`** `const Output<T> &`

Internal [Operator](operator) output declaration.

---

### configure \[#configure]

#### Overload 1

```cpp showLineNumbers={false}
template <PublishedPayload T>
InputPortConfigurator<T> holoscan::Graph::configure(
    const Input<T> &port
)
```

Create a throwing configurator for one Graph-owned input.

**Returns:** Short-lived fluent configurator referencing stable authoring identity.

**Throws:** `RuntimeError` if `port` is foreign, stale, or structurally unknown.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`port`** `const Input<T> &`

[Exact](../structs/exact) input declaration.

---

#### Overload 2

```cpp showLineNumbers={false}
template <PublishedPayload T>
OutputPortConfigurator<T> holoscan::Graph::configure(
    const Output<T> &port
)
```

Create a throwing configurator for one non-Tensor output.

**Returns:** Short-lived fluent configurator referencing stable authoring identity.

**Throws:** `RuntimeError` if `port` is foreign, stale, or structurally unknown.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted non-Tensor local payload type.

---

**Parameters**

**`port`** `const Output<T> &`

[Exact](../structs/exact) output declaration.

---

#### Overload 3

```cpp showLineNumbers={false}
template <PublishedPayload T>
TensorOutputPortConfigurator & holoscan::Graph::configure(
    const Output<T> &port
)
```

Return the stable Graph-owned configurator for a descriptor-backed [Tensor](tensor) output.

**Returns:** Stable configurator reference valid until `Graph` destruction.

**Template parameters**

**`T`** `PublishedPayload`

Admitted descriptor-backed [Tensor](tensor) schema payload.

---

**Parameters**

**`port`** `const Output<T> &`

[Exact](../structs/exact) output declaration.

---

#### Overload 4

```cpp showLineNumbers={false}
TensorOutputPortConfigurator & holoscan::Graph::configure(
    Output<Tensor> &port
)
```

Return the stable Graph-owned configurator for a [Tensor](tensor) output.

**Returns:** Stable configurator reference valid until `Graph` destruction.

**Throws:** `RuntimeError` if `port` is foreign, stale, or structurally unknown.

**Parameters**

**`port`** `Output<Tensor> &`

[Exact](../structs/exact) mutable output declaration.

---

#### Overload 5

```cpp showLineNumbers={false}
TensorOutputPortConfigurator & holoscan::Graph::configure(
    const Output<Tensor> &port
)
```

Return the stable Graph-owned configurator for a [Tensor](tensor) output.

**Returns:** Stable configurator reference valid until `Graph` destruction.

**Throws:** `RuntimeError` if `port` is foreign, stale, or structurally unknown.

**Parameters**

**`port`** `const Output<Tensor> &`

[Exact](../structs/exact) output declaration.

---

#### Overload 6

```cpp showLineNumbers={false}
template <PublishedPayload SourceT, PublishedPayload TargetT>
FlowConfigurator<SourceT, TargetT> holoscan::Graph::configure(
    FlowHandle<SourceT, TargetT> flow
)
```

Create a throwing configurator for one authored flow.

**Returns:** Short-lived fluent configurator referencing stable edge identity.

**Throws:** `RuntimeError` if `flow` is foreign or stale.

**Template parameters**

**`SourceT`** `PublishedPayload`

[Exact](../structs/exact) source payload type retained by the flow handle.

---

**`TargetT`** `PublishedPayload`

[Exact](../structs/exact) target payload type retained by the flow handle.

---

**Parameters**

**`flow`** `FlowHandle<SourceT, TargetT>`

[Exact](../structs/exact) flow handle owned by this `Graph`.

---

### try_configure \[#tryconfigure]

#### Overload 1

```cpp showLineNumbers={false}
template <PublishedPayload T>
expected<InputPortConfigurator<T>, Error> holoscan::Graph::try_configure(
    const Input<T> &port
)
```

Try to create an input configurator without throwing.

**Returns:** Configurator or typed lookup/ownership error.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted local payload type.

---

**Parameters**

**`port`** `const Input<T> &`

[Exact](../structs/exact) input declaration.

---

#### Overload 2

```cpp showLineNumbers={false}
template <PublishedPayload T>
expected<OutputPortConfigurator<T>, Error> holoscan::Graph::try_configure(
    const Output<T> &port
)
```

Try to create a non-Tensor output configurator without throwing.

**Returns:** Configurator or typed lookup/ownership error.

**Template parameters**

**`T`** `PublishedPayload`

[Exact](../structs/exact) admitted non-Tensor local payload type.

---

**Parameters**

**`port`** `const Output<T> &`

[Exact](../structs/exact) output declaration.

---

#### Overload 3

```cpp showLineNumbers={false}
template <PublishedPayload T>
expected<TensorOutputPortConfigurator, Error> holoscan::Graph::try_configure(
    const Output<T> &port
)
```

Try to create a descriptor-backed [Tensor](tensor) output configurator.

**Returns:** Configurator value or typed lookup/ownership error.

**Template parameters**

**`T`** `PublishedPayload`

Admitted descriptor-backed [Tensor](tensor) schema payload.

---

**Parameters**

**`port`** `const Output<T> &`

[Exact](../structs/exact) output declaration.

---

#### Overload 4

```cpp showLineNumbers={false}
expected<TensorOutputPortConfigurator, Error> holoscan::Graph::try_configure(
    Output<Tensor> &port
)
```

Try to create a value [Tensor](tensor) output configurator without throwing.

**Returns:** Configurator value or typed lookup/ownership error.

**Parameters**

**`port`** `Output<Tensor> &`

[Exact](../structs/exact) mutable [Tensor](tensor) output declaration.

---

#### Overload 5

```cpp showLineNumbers={false}
expected<TensorOutputPortConfigurator, Error> holoscan::Graph::try_configure(
    const Output<Tensor> &port
)
```

Try to create a value [Tensor](tensor) output configurator without throwing.

**Returns:** Configurator value or typed lookup/ownership error.

**Parameters**

**`port`** `const Output<Tensor> &`

[Exact](../structs/exact) [Tensor](tensor) output declaration.

---

#### Try to create a flow configurator without throwing

```cpp showLineNumbers={false}
template <PublishedPayload SourceT, PublishedPayload TargetT>
expected<FlowConfigurator<SourceT, TargetT>, Error> holoscan::Graph::try_configure(
    FlowHandle<SourceT, TargetT> flow
)
```

Try to create a flow configurator without throwing.

**Returns:** Configurator or typed ownership/staleness error.

**Template parameters**

**`SourceT`** `PublishedPayload`

[Exact](../structs/exact) source payload type retained by the flow handle.

---

**`TargetT`** `PublishedPayload`

[Exact](../structs/exact) target payload type retained by the flow handle.

---

**Parameters**

**`flow`** `FlowHandle<SourceT, TargetT>`

[Exact](../structs/exact) flow handle owned by this `Graph`.

---

### import_topic \[#importtopic]

#### Overload 1

```cpp showLineNumbers={false}
template <detail::ExternalTopicPayload T>
ImportedTopic<T> holoscan::Graph::import_topic(
    std::string_view uri,
    TopicOptions options = {}
)
```

Declare an intrinsic external-to-Graph typed topic boundary.

> **Note**
>
> On first external use of a derived `Graph`, Core completes or terminally fails composition before constructing the requested boundary port.

> **Note**
>
> The value parameter is intentional: it defines one immutable authoring snapshot while Core deep-copies every view-bearing field before this call returns.

> **Note**
>
> Ordinary typed validation rejection consumes the next mixed external declaration ordinal. An exception before publication restores that ordinal.

**Returns:** Typed handle exposing the stable Graph-side output declaration.

**Throws:** `RuntimeError` if identity, URI, options, bounds, or name validation fails.

**Template parameters**

**`T`** `detail::ExternalTopicPayload`

[Exact](../structs/exact) portable scalar, [Tensor](tensor), schema-root, or explicit POD payload type.

---

**Parameters**

**`uri`** `std::string_view`

Nonempty bounded `holomq://` topic URI copied before return.

---

**`options`** `TopicOptions` — default: \{}

Complete cold boundary contract copied before return.

---

#### Overload 2

```cpp showLineNumbers={false}
template <detail::ExternalTopicPayload T>
ImportedTopic<T> holoscan::Graph::import_topic(
    std::string_view uri,
    TopicOptions options,
    DescriptorTensorTopicContract<T> tensors
)
```

Declare a descriptor-backed schema external-to-Graph topic boundary.

**Returns:** Typed handle exposing the stable Graph-side output declaration.

**Throws:** `RuntimeError` if identity, URI, field inventory, bounds, or name validation fails.

**Template parameters**

**`T`** `detail::ExternalTopicPayload`

Owning singular or multi-Tensor descriptor-backed schema type.

---

**Parameters**

**`uri`** `std::string_view`

Nonempty bounded `holomq://` topic URI copied before return.

---

**`options`** `TopicOptions`

Common cold boundary contract copied before return.

---

**`tensors`** `DescriptorTensorTopicContract<T>`

Complete typed [Tensor](tensor) field inventory copied before return.

---

### export_topic \[#exporttopic]

#### Overload 1

```cpp showLineNumbers={false}
template <detail::ExternalTopicPayload T>
ExportedTopic<T> holoscan::Graph::export_topic(
    std::string_view uri,
    TopicOptions options = {}
)
```

Declare an intrinsic Graph-to-external typed topic boundary.

> **Note**
>
> On first external use of a derived `Graph`, Core completes or terminally fails composition before constructing the requested boundary port.

> **Note**
>
> The value parameter is intentional: it defines one immutable authoring snapshot while Core deep-copies every view-bearing field before this call returns.

> **Note**
>
> Ordinary typed validation rejection consumes the next mixed external declaration ordinal. An exception before publication restores that ordinal.

**Returns:** Typed handle exposing the stable Graph-side input declaration.

**Throws:** `RuntimeError` if identity, URI, options, bounds, or name validation fails.

**Template parameters**

**`T`** `detail::ExternalTopicPayload`

[Exact](../structs/exact) portable scalar, [Tensor](tensor), schema-root, or explicit POD payload type.

---

**Parameters**

**`uri`** `std::string_view`

Nonempty bounded `holomq://` topic URI copied before return.

---

**`options`** `TopicOptions` — default: \{}

Complete cold boundary contract copied before return.

---

#### Overload 2

```cpp showLineNumbers={false}
template <detail::ExternalTopicPayload T>
ExportedTopic<T> holoscan::Graph::export_topic(
    std::string_view uri,
    TopicOptions options,
    DescriptorTensorTopicContract<T> tensors
)
```

Declare a descriptor-backed schema Graph-to-external topic boundary.

**Returns:** Typed handle exposing the stable Graph-side input declaration.

**Throws:** `RuntimeError` if identity, URI, field inventory, bounds, or name validation fails.

**Template parameters**

**`T`** `detail::ExternalTopicPayload`

Owning singular or multi-Tensor descriptor-backed schema type.

---

**Parameters**

**`uri`** `std::string_view`

Nonempty bounded `holomq://` topic URI copied before return.

---

**`options`** `TopicOptions`

Common cold boundary contract copied before return.

---

**`tensors`** `DescriptorTensorTopicContract<T>`

Complete typed [Tensor](tensor) field inventory copied before return.

---

### region \[#region]

```cpp showLineNumbers={false}
RegionHandle holoscan::Graph::region(
    std::string_view name
)
```

Add one uniquely named backend-neutral policy region.

**Returns:** Fluent region handle.

**Throws:** `RuntimeError` if `name` is invalid or duplicated.

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 name copied before return.

---

### partition \[#partition]

```cpp showLineNumbers={false}
PartitionHandle holoscan::Graph::partition(
    std::string_view name
)
```

Add one uniquely named developer-preview manual execution partition.

> **Note**
>
> Without [auto_partition_remaining](#autopartitionremaining) or [PartitionHandle::include_all](partitionhandle#includeall), compile requires all partitions to be nonempty and to cover every executable [Operator](operator) exactly once.

> **Note**
>
> Manual partitions and [region](#region) declarations are orthogonal; regions may overlap partition boundaries.

> **Note**
>
> Direct root Operators and selected child subtrees may anchor automatic remainder. Selected subtrees include every descendant [Operator](operator) and must not declare partitions internally. A root [PartitionHandle::include_all](partitionhandle#includeall) covers the complete application.

**Returns:** Fluent partition handle accepting direct Operators and complete embedded instances.

**Throws:** `RuntimeError` if `name` is invalid or duplicated.

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 name copied before return.

---

### auto_partition_remaining \[#autopartitionremaining]

```cpp showLineNumbers={false}
void holoscan::Graph::auto_partition_remaining()
```

Automatically partition Operators omitted from exact authored partitions.

> **Note**
>
> The request is idempotent and may precede or follow exact partition authoring. Compilation rejects a request with no nonempty exact partition anchor.

**Throws:** `RuntimeError` if a partition already uses [PartitionHandle::include_all](partitionhandle#includeall).

### lifecycle \[#lifecycle]

```cpp showLineNumbers={false}
GraphLifecycleBuilder holoscan::Graph::lifecycle()
```

Create a lifecycle ordering/permission authoring builder.

**Returns:** Short-lived builder tied to this `Graph`.

### view \[#view]

```cpp showLineNumbers={false}
GraphView holoscan::Graph::view()
```

Freeze and return one immutable deep-owning authoring snapshot.

**Returns:** Snapshot that remains valid across `Graph` mutation and destruction.

**Throws:** `RuntimeError` if lazy composition failed or observation is reentrant.

### add_clock \[#addclock]

```cpp showLineNumbers={false}
template <std::derived_from< Clock > ClockT, typename... Args>
ClockKey holoscan::Graph::add_clock(
    std::string_view name,
    Args &&... args
)
```

Add one Graph-owned replayable clock declaration.

> **Note**
>
> On first external use of a derived `Graph`, Core completes or terminally fails composition before constructing the requested clock factory.

> **Note**
>
> Registration constructs one [Clock](clock) for validation and discards it. A later compiler or [RunSession](runsession) replays the retained factory to create its own ordinary [Clock](clock); only [`bind_shared_clock()`](#bindsharedclock) retains a live instance.

> **Preconditions**
>
> Every normalized capture is copy-constructible and follows its ordinary C++ copy semantics. Obvious top-level borrowed forms and `Graph` authoring handles are rejected. Checks are shallow; nested borrows remain the application's lifetime responsibility. Construction must be repeatable, and constructor side effects are not authoritative runtime state.

**Returns:** Owned named cold clock key.

**Throws:** `RuntimeError` if construction, naming, or registration fails.

**Template parameters**

**`ClockT`** `std::derived_from< Clock >`

Concrete [Clock](clock) type.

---

**`Args`** `typename...`

Constructor capture argument types.

---

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 clock name.

---

**`args`** `Args &&...`

Constructor values copied under the same ownership precondition as [`op`](#op).

---

### bind_shared_clock \[#bindsharedclock]

```cpp showLineNumbers={false}
ClockKey holoscan::Graph::bind_shared_clock(
    std::string_view name,
    std::shared_ptr<Clock> clock
)
```

Bind one explicitly shared live clock into cold `Graph` ownership.

**Returns:** Owned named cold clock key.

**Throws:** `RuntimeError` if naming or pointer validation fails.

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 clock name.

---

**`clock`** `std::shared_ptr<Clock>`

Non-null shared clock retained by `Graph` state.

---

### import_clock \[#importclock]

```cpp showLineNumbers={false}
ClockKey holoscan::Graph::import_clock(
    std::string_view name
)
```

Declare one explicit clock dependency for a reusable `Graph`.

> **Note**
>
> An import creates no runtime clock. Every embedded instance must be bound explicitly by its direct parent before compilation.

**Returns:** Owned named import key that contracts and conversions may reference.

**Throws:** `RuntimeError` if naming or registration fails.

**Parameters**

**`name`** `std::string_view`

Nonempty unique bounded UTF-8 clock import name.

---

### bind_clock \[#bindclock]

```cpp showLineNumbers={false}
template <typename G>
Graph & holoscan::Graph::bind_clock(
    const GraphHandle<G> &child,
    ClockKey child_import,
    ClockKey parent_clock
)
```

Bind one embedded `Graph` clock import to one exact parent clock.

> **Note**
>
> Resolution follows only these instance-qualified records. It never searches an ancestor scope by clock name.

**Returns:** This `Graph`.

**Throws:** `RuntimeError` for a foreign/stale child handle, a non-import child key, an unknown parent key, or a duplicate/conflicting binding.

**Template parameters**

**`G`** `typename`

Concrete reusable `Graph` type.

---

**Parameters**

**`child`** `const GraphHandle<G> &`

[Exact](../structs/exact) live child instance owned by this `Graph`.

---

**`child_import`** `ClockKey`

Named clock import declared by that child root.

---

**`parent_clock`** `ClockKey`

Named clock declaration or import in this `Graph`.

---

### set_default_clock \[#setdefaultclock]

```cpp showLineNumbers={false}
Graph & holoscan::Graph::set_default_clock(
    ClockKey key
)
```

Select one previously declared named clock as `Graph` default.

**Returns:** This `Graph`.

**Throws:** `RuntimeError` if `key` is default, empty, or not declared.

**Parameters**

**`key`** `ClockKey`

Existing non-default named key.

---

### default_clock \[#defaultclock]

```cpp showLineNumbers={false}
ClockKey holoscan::Graph::default_clock()
```

Return the selected default clock key.

**Returns:** Named key, or the distinct default/omitted key when none was selected.

**Throws:** `RuntimeError` if lazy composition failed or observation is reentrant.

### add_clock_conversion \[#addclockconversion]

```cpp showLineNumbers={false}
Graph & holoscan::Graph::add_clock_conversion(
    ClockKey from,
    ClockKey to,
    AffineClockConversion conversion
)
```

Add one immutable directed affine clock conversion.

> **Note**
>
> Core reduces the positive ratio to lowest terms. Repeating the same pair with an equivalent canonical ratio and equal offset is idempotent.

**Returns:** This `Graph`.

**Throws:** `RuntimeError` for missing/self clocks, an invalid scale, a conflicting conversion for the same directed pair, or a directed cycle.

**Parameters**

**`from`** `ClockKey`

Existing named source clock.

---

**`to`** `ClockKey`

Existing distinct named destination clock.

---

**`conversion`** `AffineClockConversion`

Positive exact rate and signed nanosecond offset.

---

### compose \[#compose]

```cpp showLineNumbers={false}
virtual void holoscan::Graph::compose()
```

Author a derived `Graph` body during Core-managed lazy composition.

Core invokes this override at most once after derived construction. Normal authoring verbs are valid inside the active transaction. Topology observers and other same-Graph paths that re-enter the composition gate fail with `GRAPH_COMPOSE_REENTRANT`; a terminal failure is retained and replayed.

> **Warning**
>
> Do not author from the derived constructor and do not call this virtual function directly. Constructor misuse and direct self-recursion have no promised runtime diagnosis.

> **Warning**
>
> The complete most-derived `Graph` must remain alive for the entire callback; concurrent destruction is outside the `Graph` lifetime contract.

### embedding_type_identity \[#embeddingtypeidentity]

```cpp showLineNumbers={false}
virtual const void * holoscan::Graph::embedding_type_identity() const noexcept
```

Supply a process-stable logical type identity for a language-hosted `Graph` adapter.

> **Note**
>
> Ordinary C++ `Graph` subclasses should retain the default. Language bindings that host multiple logical graph types behind one C++ adapter may override this hook so recursion checks distinguish those hosted types without weakening cycle detection.

> **Note**
>
> This virtual is deliberately appended after the pre-existing [`compose()`](#compose) slot so adding the hosted-language hook does not change the slot used by existing `Graph` subclasses.

**Returns:** A non-null identity shared by every instance of the same logical hosted type, or `nullptr` to use the concrete C++ `Graph` type.

### add_operator_with_initial_params \[#addoperatorwithinitialparams]

```cpp showLineNumbers={false}
template <std::derived_from< OperatorBase > Op>
OperatorHandle<Op> holoscan::Graph::add_operator_with_initial_params(
    std::string_view name,
    const typename Op::Params &params
)
```

### add_flow_projected \[#addflowprojected]

```cpp showLineNumbers={false}
template <PublishedPayload SchemaT>
FlowHandle<SchemaT, Tensor> holoscan::Graph::add_flow_projected(
    const Output<SchemaT> &source,
    const Input<Tensor> &target,
    TensorFieldSelector<SchemaT> selector,
    ConnectionOptions options
)
```

Register one schema-to-Tensor edge after the field identity is known.

---

## Member variables

| Name     | Type                                    | Description |
| -------- | --------------------------------------- | ----------- |
| `state_` | `std::shared_ptr< detail::GraphState >` |             |