adrian0010 / Percolation

1 stars 0 forks source link

Minimum Diameter of Channel #7

Closed discoleo closed 1 year ago

discoleo commented 1 year ago

Minimum Diameter of Channel

Idea: Algorithm

Step 1:

Step 2:\ Grow the block (component -1 in the matrix) with 1 unit vertically downwards (or horizontally to the right). Repeat flood-operation for that channel. Repeat the growth process until the channel no longer percolates. This is only an initial idea for the algorithm.

discoleo commented 1 year ago

Using min_cut algorithm

graph = as.graph.percol(m, id = ...);
idE = attr(graph, "entry");
idC = min_cut(graph, source = idE[1], target = idE[2], only.values = FALSE);
# idC$value is the width of the minimal cut;
# idC$cut contains the edges that have to be cut;

You can colour the border around the nodes in idC$cut:

Helper Functions

  1. Implement a helper function to identify all border-nodes around the edges: This function identifies only the border around the narrow points of the channel!

    as.surface.cut = function(m, npos) {....};

  2. Function to draw the border: plot.minCut

    • see the code of the function plot.surface in file Plot.R;

    plot.minCut = function(m, npos, col = "#1624C0") { img = toRaster(m); img[npos] = col; plot.rs(img); }

Main Function

Implement a new function in Analysis.R:

minCut = function(m, id) {...}

The function will:

Plot using the plot.minCut function (see above).