medpy.graphcut.graph.GCGraph#

class medpy.graphcut.graph.GCGraph(nodes, edges)[source]#

A graph representation that works directly with the maxflow.GraphDouble graph as base. It is therefore less flexible as graph.Graph, but leads to lower memory requirements.

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 0 and be continuous. This is not actually checked, so be careful.

This wrapper tries to catch the most usual exception that can occur in the underlying C++ implementation and to convert them into catchable and meaningful error messages.

__init__(nodes, edges)[source]#

Initialize.

Parameters:
nodesint

The number of nodes in the graph.

edgesint

The number of edges in the graph.

Methods

__init__(nodes, edges)

Initialize.

get_edge_count()

Get the number of edges.

get_graph()

Get the C++ graph.

get_node_count()

Get the number of nodes.

get_nodes()

Get the nodes.

set_nweight(node_from, node_to, ...)

Set a single n-weight / edge-weight.

set_nweights(nweights)

Set multiple n-weights / edge-weights.

set_sink_nodes(sink_nodes)

Set multiple sink nodes and compute their t-weights.

set_source_nodes(source_nodes)

Set multiple source nodes and compute their t-weights.

set_tweight(node, weight_source, weight_sink)

Set a single t-weight / terminal-weight.

set_tweights(tweights)

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

set_tweights_all(tweights)

Set all t-weights at once.

Attributes

MAX

The maximum value a terminal weight can take.