Closed discoleo closed 1 year ago
There is a problem if the entry-nodes are part of the min-cut:
remove the entry-nodes from the partition (see also the helper function);
minCut = function(m, id) { graph = as.graph.percol(m, id = id); idE = attr(graph, "entry"); idC = min_cut(graph, source = idE[1], target = idE[2], value.only = FALSE); edge = as.integer(idC$cut); ids = get.edgelist(graph)[edge,]; idEntry = which(ids %in% idE); # Graph Entry if(length(idEntry) > 0) { print("Min-Cut: Graph Entry!"); ids = ids[ - idEntry]; } idN = which.neighbors(m, ids); print(paste0("Finished Neighbours: ", length(idN))); # for DEBUG lst = list(value = idC$value, nodes = idC$cut, neighbors = idN, part = prune.part(idC$partition2, idE)); return (lst); }
Also make function which.neighbors more robust:
which.neighbors = function(m, npos, val = -1) { if(length(npos) == 0) return(integer(0)); # ...
The entry-nodes must be removed from the partition as well:
prune.part = function(x, id) { idE = which(x %in% id); x = x[ - idE]; invisible(x); }
Bug in Function minCut: Entry Nodes
There is a problem if the entry-nodes are part of the min-cut:
R Code
remove the entry-nodes from the partition (see also the helper function);
minCut = function(m, id) { graph = as.graph.percol(m, id = id); idE = attr(graph, "entry"); idC = min_cut(graph, source = idE[1], target = idE[2], value.only = FALSE); edge = as.integer(idC$cut); ids = get.edgelist(graph)[edge,]; idEntry = which(ids %in% idE); # Graph Entry if(length(idEntry) > 0) { print("Min-Cut: Graph Entry!"); ids = ids[ - idEntry]; } idN = which.neighbors(m, ids); print(paste0("Finished Neighbours: ", length(idN))); # for DEBUG lst = list(value = idC$value, nodes = idC$cut, neighbors = idN, part = prune.part(idC$partition2, idE)); return (lst); }
Also make function which.neighbors more robust: