medpy.graphcut.graph.GCGraph.set_nweight¶
-
GCGraph.
set_nweight
(node_from, node_to, weight_there, weight_back)[source]¶ Set a single n-weight / edge-weight.
Parameters: node_from : int
Node-id from the first node of the edge.
node_to : int
Node-id from the second node of the edge.
weight_there : float
Weight from first to second node (>0).
weight_back : float
Weight from second to first node (>0).
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).
ValueError
If the two node-ids of the edge are the same (graph cut does not allow self-edges).
ValueError
If one of the passed weights is <= 0.
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 unefficient.
The underlying C++ implementation allows zero weights, but these are highly undesirable for inter-node weights and therefore raise an error.