monai.deploy.core.graphs.Graph

class monai.deploy.core.graphs.Graph[source]

Bases: abc.ABC

Abstract class for graph.

Methods

__init__()

add_flow(op_u, op_v, io_map)

Add an edge to the graph.

add_operator(op)

Add a node to the graph.

gen_next_operators(op)

Get next operators.

gen_worklist()

Get worklist.

get_io_map(op_u, op_v)

Get a mapping from the source operator’s output label to the destination operator’s input label.

get_operators()

Get all operators.

get_root_operators()

Get all root operators.

is_leaf(op)

Check if the operator is a leaf operator.

is_root(op)

Check if the operator is a root operator.

abstract add_flow(op_u, op_v, io_map)[source]

Add an edge to the graph.

Parameters
  • op_u (Operator) – A source operator.

  • op_v (Operator) – A destination operator.

  • io_map (Dict[str, Set[str]]) – A dictionary of mapping from the source operator’s label to the destination operator’s label(s).

abstract add_operator(op)[source]

Add a node to the graph.

abstract gen_next_operators(op)[source]

Get next operators.

Return type

Generator[Optional[Operator], None, None]

abstract gen_worklist()[source]

Get worklist.

Return type

Generator[Optional[Operator], None, None]

abstract get_io_map(op_u, op_v)[source]

Get a mapping from the source operator’s output label to the destination operator’s input label. :type op_u: Operator :param op_u: A source operator. :type op_u: Operator :param op_v: A destination operator. :type op_v: Operator

Return type

Dict[str, Set[str]]

Returns

A dictionary of mapping from the source operator’s output label to the destination operator’s input label(s).

abstract get_operators()[source]

Get all operators.

Return type

Generator[Operator, None, None]

Returns

A generator of operators.

abstract get_root_operators()[source]

Get all root operators.

Return type

Generator[Operator, None, None]

Returns

A generator of root operators.

abstract is_leaf(op)[source]

Check if the operator is a leaf operator.

Parameters

op (Operator) – A node in the graph.

Return type

bool

Returns

True if the operator is a leaf operator.

abstract is_root(op)[source]

Check if the operator is a root operator.

Parameters

op (Operator) – A node in the graph.

Return type

bool

Returns

True if the operator is a root operator.