NVIDIA Holoscan SDK v3.5.0

Template Class FlowGraph

Base Type

template<typename NodeT = OperatorNodeType, typename EdgeDataElementT = OperatorEdgeDataElementType>
class FlowGraph : public holoscan::Graph<OperatorNodeType, OperatorEdgeDataElementType>

Public Types

using NodeType = NodeT
using NodePredicate = std::function<bool(const NodeType&)>
using EdgeDataElementType = EdgeDataElementT
using EdgeDataType = std::shared_ptr<EdgeDataElementType>

Public Functions

~FlowGraph() override = default
virtual void add_node(const NodeType &node) override

Add the node to the graph.

Parameters

node – The node to add.

void add_flow(const NodeType &node_u, const NodeType &node_v, const EdgeDataType &port_map) override
virtual std::optional<EdgeDataType> get_port_map(const NodeType &node_u, const NodeType &node_v) const override

Get a mapping from the source node’s port name to the destination node’s port name(s).

Parameters
  • node_u – A source node.

  • node_v – A destination node.

Returns

A map from the source node’s port name to the destination node’s port name(s).

virtual bool is_root(const NodeType &node) const override

Check if the node is a root node.

Parameters

node – A node in the graph.

Returns

true if the node is a root node.

inline virtual bool is_user_defined_root(const NodeType &node) const override

Check if the node is a user-defined root node. A user-defined root is the first node that is added to the graph.

Parameters

node – A node in the graph.

Returns

true if the node is a user-defined root node.

virtual bool is_leaf(const NodeType &node) const override

Check if the node is a leaf node.

Parameters

node – A node in the graph.

Returns

true if the node is a leaf node.

virtual std::vector<NodeType> has_cycle() const override

Returns a vector of root nodes of the cycles if the graph has cycle(s). Otherwise, an empty vector is returned.

Returns

Returns a vector of root nodes of cycles.

virtual std::vector<NodeType> get_root_nodes() const override

Get all root nodes.

The nodes are returned in the order they were added to the graph.

Returns

A vector of all root nodes.

virtual std::vector<NodeType> get_nodes() const override

Get all nodes.

The nodes are returned in the order they were added to the graph.

Returns

A vector of all nodes.

virtual std::vector<NodeType> get_next_nodes(const NodeType &node) const override

Get all nodes immediately downstream of a given node.

The nodes are returned in the order in which they were added to the graph.

Returns

A vector of all next nodes.

virtual std::vector<NodeType> get_previous_nodes(const NodeType &node) const override

Get all nodes immediately upstream of a given node.

The nodes are returned in the order in which they were added to the graph.

Parameters

node – The node to get the upstream nodes of.

Returns

A vector of all previous nodes.

virtual size_t get_outdegree(const NodeType &node, const std::string &port_name) const override

Get the outdegree of a given node of a given port.

Parameters
  • node – The node to get the outdegree of.

  • port_name – The name of the port in the given node.

Returns

The outdegree of the given node of the given port.

virtual std::pair<std::map<std::string, std::vector<std::string>>, std::map<std::string, std::vector<std::string>>> get_port_connectivity_maps() const override

Get port connectivity maps for the graph.

Returns two maps that describe the connectivity between input and output ports:

  1. Input-to-Output map: Keys are input port unique IDs, values are vectors of output port unique IDs that connect to this input port.

  2. Output-to-Input map: Keys are output port unique IDs, values are vectors of input port unique IDs that this output port connects to.

For multi-receiver ports, each individual port (e.g., “in:0”, “in:1”, “in:2”) is listed as a separate key.

For OperatorFlowGraph the unique ID has format: “<fragment_name>.<operator_name>.<port_name>” (or just <operator_name>.<port_name> if no fragment name was assigned).

For FragmentGraph the unique ID has format: “<fragment_name>.<port_name>”.

Returns

A pair containing (input_to_output_map, output_to_input_map)

virtual std::string port_map_description() const override

Get a YAML formatted description of the port connectivity maps.

Returns a string containing the port connectivity information in YAML format. The output includes both input-to-output and output-to-input mappings.

Example output for the following computation graph

tx -> mx -&#8212; rx1 ___ rx2

(assume each operator has one input port named ‘in’ and one output port named ‘out’)

Copy
Copied!
            

input_to_output: mx.in: - tx.out rx1.in: - mx.out rx2.in: - mx.out output_to_input: tx.out: - mx.in mx.out: - rx1.in - rx2.in

Returns

A YAML formatted string describing the port connectivity

NodeType find_node(const NodePredicate &pred) const override
virtual NodeType find_node(const NodeType &node) const override

Find a node in the graph that is equal to the given node.

Parameters

node – The node to find.

Returns

The node in the graph if found, otherwise nullptr.

virtual NodeType find_node(const std::string &name) const override

Find a node in the graph whose name is equal to the given name.

Parameters

name – The name to find.

Returns

The node in the graph if found, otherwise nullptr.

virtual void remove_node(const NodeType &node) override

Remove a node (and all its edges) from the graph.

Parameters

node – The node to remove.

struct NodeTypeCompare

Public Functions

inline NodeTypeCompare()
inline explicit NodeTypeCompare(const std::list<NodeType> *nodes)
inline bool operator()(const NodeType &lhs, const NodeType &rhs) const

Public Members

const std::list<NodeType> *ordered_nodes

Previous Class FirstFitAllocatorBase
Next Class Fragment
© Copyright 2022-2025, NVIDIA. Last updated on Sep 4, 2025.