holoscan::FlowGraph

Beta
View as Markdown
template <typename NodeT, typename EdgeDataElementT>
class FlowGraph

Abstract base class for all flow graphs.

#include <holoscan/flow_graph.hpp>

Template parameters

NodeT
typename
EdgeDataElementT
typename

Constructors

FlowGraph

holoscan::FlowGraph<NodeT, EdgeDataElementT>::FlowGraph() = default

Destructor

~FlowGraph

virtual holoscan::FlowGraph<NodeT, EdgeDataElementT>::~FlowGraph() = default

Assignment operators

operator=

FlowGraph & holoscan::FlowGraph<NodeT, EdgeDataElementT>::operator=(
const FlowGraph &
) = delete

Methods

add_node

virtual void holoscan::FlowGraph<NodeT, EdgeDataElementT>::add_node(
const NodeT &node
)

Add the node to the graph.

Parameters

node
const NodeT &

The node to add.

add_flow

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

Add an edge to the graph.

Parameters

node_u
const NodeType &

A source node.

node_v
const NodeType &

A destination node.

port_map
const EdgeDataType &

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

get_port_map

virtual std::optional<EdgeDataType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_port_map(
const NodeType &node_u,
const NodeType &node_v
) const

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_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.

is_root

virtual bool holoscan::FlowGraph<NodeT, EdgeDataElementT>::is_root(
const NodeType &node
) const

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

virtual bool holoscan::FlowGraph<NodeT, EdgeDataElementT>::is_user_defined_root(
const NodeType &node
) const

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

virtual bool holoscan::FlowGraph<NodeT, EdgeDataElementT>::is_leaf(
const NodeType &node
) const

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

virtual std::vector<NodeType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::has_cycle() const

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

virtual std::vector<NodeType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_root_nodes() const

Get all root nodes.

Returns: A vector of root nodes.

get_nodes

virtual std::vector<NodeType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_nodes() const

Get all nodes.

The order of the nodes is not guaranteed.

Returns: A vector of all nodes.

get_next_nodes

virtual std::vector<NodeType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_next_nodes(
const NodeType &node
) const

Get the next nodes of the given node.

Returns: A vector of next nodes.

Parameters

node
const NodeType &

A node in the graph.

get_outdegree

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

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 &

A node in the graph.

port_name
const std::string &

The name of the port in the given node.

get_indegree

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

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 &

A node in the graph.

port_name
const std::string &

The name of the port in the given node.

find_node

virtual NodeType holoscan::FlowGraph<NodeT, EdgeDataElementT>::find_node(
const NodePredicate &pred
) const

Find a node in the graph that satisfies the given predicate.

Returns: The node if found, otherwise nullptr.

Parameters

pred
const NodePredicate &

A predicate.

get_previous_nodes

virtual std::vector<NodeType> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_previous_nodes(
const NodeType &node
) const

Get the previous nodes of the given node.

Returns: A vector of previous nodes.

Parameters

node
const NodeType &

A node in the graph.

context

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

Set the context.

Parameters

context
void *

The context.

remove_node

virtual void holoscan::FlowGraph<NodeT, EdgeDataElementT>::remove_node(
const NodeType &node
)

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

Parameters

node
const NodeType &

The node to remove.

get_port_connectivity_maps

virtual std::pair<std::map<std::string, std::vector<std::string>>, std::map<std::string, std::vector<std::string>>> holoscan::FlowGraph<NodeT, EdgeDataElementT>::get_port_connectivity_maps() const

Get port connectivity maps for the graph.

Returns a pair of two maps:

  1. Input ports to connected output ports mapping
  2. Output ports to connected input ports mapping

Each port is identified by a unique string.

Returns: A pair containing (input_to_output_map, output_to_input_map) where:input_to_output_map: Maps input port IDs to lists of connected output port IDs output_to_input_map: Maps output port IDs to lists of connected input port IDs

port_map_description

virtual std::string holoscan::FlowGraph<NodeT, EdgeDataElementT>::port_map_description() const

Get a YAML-formatted description of the port connectivity maps.

Returns a human-readable YAML string that describes the port connectivity of the graph.

Returns: A YAML-formatted string describing the port connectivity maps


Types

Typedefs

NameDefinition
NodeTypeNodeT
NodePredicatestd::function< bool(const NodeT &)>
EdgeDataElementTypeEdgeDataElementT
EdgeDataTypestd::shared_ptr< EdgeDataElementT >

Member variables

NameTypeDescription
context_void *The context.