holoscan::FlowGraphImpl

Beta
View as Markdown
template <typename NodeT, typename EdgeDataElementT>
class FlowGraphImpl
#include <holoscan/flow_graph_impl.hpp>

Template parameters

NodeT
typename
EdgeDataElementT
typename

Inherits from: holoscan::FlowGraph< NodeT, EdgeDataElementT > (public)


Constructors

Destructor

~FlowGraphImpl

holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::~FlowGraphImpl() override = defaultholoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::~FlowGraphImpl() override = default

Methods

add_node

void holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::add_node(
const NodeType &node
) override

Add the node to the graph.

Parameters

node
const NodeType &

The node to add.

add_flow

void holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::add_flow(
const NodeType &node_u,
const NodeType &node_v,
const EdgeDataType &port_map
) override

get_port_map

std::optional<EdgeDataType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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).

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

Parameters

node_u
const NodeType &

A source node.

node_v
const NodeType &

A destination node.

is_root

bool holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::is_root(
const NodeType &node
) const override

Check if the node is a root node.

Returns: true if the node is a root node.

Parameters

node
const NodeType &

A node in the graph.

is_user_defined_root

bool holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

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

Parameters

node
const NodeType &

A node in the graph.

is_leaf

bool holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::is_leaf(
const NodeType &node
) const override

Check if the node is a leaf node.

Returns: true if the node is a leaf node.

Parameters

node
const NodeType &

A node in the graph.

has_cycle

std::vector<NodeType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

get_root_nodes

std::vector<NodeType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

get_nodes

std::vector<NodeType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

get_next_nodes

std::vector<NodeType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

get_previous_nodes

std::vector<NodeType> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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.

Returns: A vector of all previous nodes.

Parameters

node
const NodeType &

The node to get the upstream nodes of.

get_outdegree

size_t holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::get_outdegree(
const NodeType &node,
const std::string &port_name
) const override

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

Returns: The outdegree of the given node of the given port.

Parameters

node
const NodeType &

The node to get the outdegree of.

port_name
const std::string &

The name of the port in the given node.

get_indegree

size_t holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::get_indegree(
const NodeType &node,
const std::string &port_name
) const override

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

Returns: The indegree of the given node of the given port.

Parameters

node
const NodeType &

The node to get the indegree of.

port_name
const std::string &

The name of the port in the given node.

get_port_connectivity_maps

std::pair<std::map<std::string, std::vector<std::string>>, std::map<std::string, std::vector<std::string>>> holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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 OperatorFlowGraphImpl the unique ID has format: “<fragment_name>.<operator_name>.<port_name>” (or just <operator_name>.<port_name> if no fragment name was assigned).

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

Returns: A pair containing (input_to_output_map, output_to_input_map)

port_map_description

std::string holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::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 -— rx1 ___ rx2

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

Returns: A YAML formatted string describing the port connectivity

Example

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

find_node

NodeType holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::find_node(
const NodePredicate &pred
) const override

remove_node

void holoscan::FlowGraphImpl<NodeT, EdgeDataElementT>::remove_node(
const NodeType &node
) override

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

Parameters

node
const NodeType &

The node to remove.

is_empty

virtual bool holoscan::FlowGraph<NodeT, EdgeDataElementT>::is_empty() const

Check if the graph is empty.

Returns: true if the graph is empty. Otherwise, false.

context

virtual void holoscan::FlowGraph<NodeT, EdgeDataElementT>::context(
void *context
)

Set the context.

Parameters

context
void *

The context.


Types

Typedefs

NameDefinition
NodeTypeNodeT
NodePredicatestd::function< bool(const NodeType &)>
EdgeDataElementTypeEdgeDataElementT
EdgeDataTypestd::shared_ptr< EdgeDataElementType >

Member variables

NameTypeDescription
succ_std::unordered_map< NodeType, std::map< NodeType, EdgeDataType, NodeTypeCompare > >
pred_std::unordered_map< NodeType, std::map< NodeType, EdgeDataType, NodeTypeCompare > >
ordered_nodes_std::list< NodeType >Nodes in the order they were added to the graph.
name_map_std::unordered_map< std::string, NodeType >Map from node name to node.
cached_cyclic_roots_std::optional< std::vector< NodeType > >
context_void *The context.

Inner classes

NodeTypeCompare

struct holoscan::FlowGraphImpl::NodeTypeCompare
NameTypeDescription
ordered_nodesconst std::list< NodeType > *