medpy.graphcut.graph.Graph#

class medpy.graphcut.graph.Graph[source]#

Represents a graph suitable for further processing with the graphcut package.

The graph contains nodes, edges (directed) between the nodes (n-edges), edges between two terminals (called source and sink) and the nodes (t-edges), and a weight for each edge.

Notes

The node-ids used by the graph are assumed to start with 1 and be continuous. This is not actually checked, except when calling the inconsistent() method, so be careful.

__init__()[source]#

Methods

__init__()

add_tweights(tweights)

Adds t-weights to the current collection of t-weights, overwriting already existing ones.

get_edges()

Get the edges.

get_node_count()

Get the number of nodes.

get_nodes()

Get the nodes.

get_nweights()

Get the nweights.

get_sink_nodes()

Get the sink nodes.

get_source_nodes()

Get the source nodes.

get_tweights()

Get the tweights.

inconsistent()

Perform some consistency tests on the graph represented by this object

set_nodes(nodes)

Set the number of graph nodes (starting from node-id = 1), excluding sink and source.

set_nweights(nweights)

Sets all n-weights.

set_sink_nodes(sink_nodes)

Set the sink nodes and compute their t-weights.

set_source_nodes(source_nodes)

Set the source nodes and compute their t-weights.

Attributes

MAX