Previous topic

medpy.graphcut.graph.GCGraph.set_source_nodes

Next topic

medpy.graphcut.graph.GCGraph.set_tweights

This Page

medpy.graphcut.graph.GCGraph.set_tweight

GCGraph.set_tweight(node, weight_source, weight_sink)[source]

Set a single t-weight / terminal-weight.

Parameters:

node : int

Node-id for which to set the terminal weights.

weight_source : float

Weight to source terminal.

weight_sink : float

Weight to sink terminal.

Raises:

ValueError

If a passed node id does not refer to any node of the graph (i.e. it is either higher than the initially set number of nodes or lower than zero).

Notes

The object does not check if the number of supplied edges in total exceeds the number passed to the init-method. If this is the case, the underlying C++ implementation will double the memory, which is very inefficient.

Terminal weights can be zero or negative.