Skip to contents

Uses a maximum flow / minimum cut algorithm (imported from igraph) to calculate the maximum flow / minimum cut from each of the factors for which `found_from` is true to each of the factors for which `found_to` is true.

calculate_robustness() is used by pipe_trace_paths().

Usage

pipe_calculate_robustness(graf)

Arguments

graf

A mapfile. To use this function, the factors table of this map must include two logical variables called `found_from` and `found_to`. If the links table contains an integer column `n`, these values are treated as the capacity of the links, otherwise the capacity for each link is taken as 1. If there are multiple links between any ordered pair of nodes, the links are combined using bundle_links()

field

An optional field by which to split the robustness calculation.

Value

A mapfile with an additional attribute `flow`, a tibble (dataframe) in which the columns are each of the factors for which `found_from` is true (if there is more than one such column, and additional "All sources" column is prepended); and in which the rows are each of the factors for which `found_to` is true (if there is more than one such row, and additional "All targets" column is prepended. The (integer) values in the table represent the maximum flow / minimum cut aka Robustness score from the corresponding source factor (column) to the corresponding target factor (row). The scores for the "All sources" column are calculated by constructing an additional factor as an ultimate source which is connected to the other sources by links of infinite capacity, and likewise for the "All targets" row. If `field` is not NULL (or not the empty string), robustness is calculated several times, once for each value of that field. In this case, what is returned is a dataframe which summarises the set of dataframes so that the value of each cell in the returned dataframe is the number of these values for which the robustness value in the corresponden is not zero. The table is sorted in descending order of the first column.

Examples

if(F)cashTransferMap %>% pipe_trace_paths(from="Cash",to="Increa",length=4) %>% pipe_merge_statements %>% pipe_calculate_robustness(field="#SourceID") %>% attr("flow")