cutcutcodec.core.edit.operation.add

Allow to append elements from the graph by managing collateral damage.

Functions

add_edge(graph, node_src, node_dst, index)

Add a stream to the graph.

add_node(graph, node, attrs)

Add a node to the graph.

Details

cutcutcodec.core.edit.operation.add.add_edge(graph: MultiDiGraph, node_src: str, node_dst: str, index: int) tuple[str, str, str][source]

Add a stream to the graph.

Parameters

graphnetwork.MultiDiGraph

The assembly graph which does not yet contain the edge to be added. The operations on this graph will be performed in-place.

node_srcstr

The name of the starting node, must be present in the graph.

node_dststr

The name of the arriving node, must be present in the graph.

indexint

The index of the output stream of the node node_src.

Returns

edgetuple[str, str, str]

The name of the edge added to the graph.

Raises

KeyError

If one of the nodes is not in the graph.

cutcutcodec.core.edit.operation.add.add_node(graph: MultiDiGraph, node: str, attrs: dict[str]) None[source]

Add a node to the graph.

The parameters can be compute by cutcutcodec.core.compilation.tree_to_graph.new_node.

Parameters

graphnetwork.MultiDiGraph

The assembly graph which does not yet contain the node to be added. The operations on this graph will be performed in-place.

nodestr

The name of the node to add. It must be new.

attrsdict[str]

The new node attributes.

Raises

KeyError

If the node is in the graph.