Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Region Adjacency Graphs (RAGs)#
This example demonstrates the use of the merge_nodes function of a Region
Adjacency Graph (RAG). The RAG class represents an undirected weighted graph
which inherits from networkx.Graph class. When a new node is formed by
merging two nodes, the edge weight of all the edges incident on the resulting
node can be updated by a user defined function weight_func.
The default behaviour is to use the smaller edge weight in case of a conflict. The example below also shows how to use a custom function to select the larger weight instead.