finesse.graph.operator_graph.OperatorGraph.add_edge

OperatorGraph.add_edge(self, unicode name: str, int from_node: int, int to_node: int)

Add an edge to the graph.

This method adds an edge from from_node to to_node in the graph. The edge is associated with a linear operator named name. If the edge already exists in the graph, or if an error occurs while adding the edge, an exception is raised.

The added linear operator is given a monotonically increasing ID value, starting from 0. See .operator_indices for a mapping of operator names to operator IDs and .indices_operator_names for a mapping of operator IDs to operator names.

Parameters
namestr

The name of the linear operator associated with the edge.

from_nodeint

The index of the node where the edge starts.

to_nodeint

The index of the node where the edge ends.

Raises
Exception

If the edge already exists in the graph (error code -4), or if an error occurs while adding the edge (any positive error code).