robustness: Calculate robustness across networks.

robustnessR Documentation

Calculate robustness across networks.

Description

This class is a wrapper for robustness calculation and visualization.

Methods

Public methods


Method new()

Usage
robustness$new(
  network_list,
  remove_strategy = c("edge_rand", "edge_strong", "edge_weak", "node_rand", "node_hub",
    "node_degree_high", "node_degree_low")[1],
  remove_ratio = seq(0, 1, 0.1),
  measure = c("Eff", "Eigen", "Pcr")[1],
  run = 10
)
Arguments
network_list

a list with multiple networks; all the networks should be trans_network object created from trans_network class of microeco package.

remove_strategy

default "edge_rand";

"edge_rand"

edges are randomly removed.

"edge_strong"

edges are removed in decreasing order of weight.

"edge_weak"

edges are removed in increasing order of weight.

"node_rand"

nodes are removed randomly.

"node_hub"

node hubs are randomly removed. The hubs include network hubs and module hubs.

"node_degree_high"

nodes are removed in decreasing order of degree.

"node_degree_low"

nodes are removed in increasing order of degree.

remove_ratio

default seq(0, 1, 0.1).

measure

default "Eff"; network robustness measures.

"Eff"

network efficiency. The average efficiency of the network is defined:

Eff = \frac{1}{N(N - 1)} \sum_{i \neq j \in G}\frac{1}{d(i, j)}

where N is the total number of nodes and d(i,j) is the shortest path between node i and node j. When the weight is found in the edge attributes, d(i,j) denotes the weighted shortest path between node i and node j. For more details, please read the references <doi: 10.1007/s11704-016-6108-z> and <doi: 10.1038/s41598-020-60298-7>.

"Eigen"

natural connectivity <doi: 10.1007/s11704-016-6108-z>. The natural connectivity can be regarded as an average eigenvalue that changes strictly monotonically with the addition or deletion of edges. It is defined:

\bar{\lambda} = \ln(\frac{1}{N} \sum_{i=1}^{N} e^{\lambda~i~})

where \lambda~i~ is the ith eigenvalue of the graph adjacency matrix. The larger the value of \bar{\lambda} is, the more robust the network is.

"Pcr"

critical removal fraction of vertices (edges) for the disintegration of networks <doi: 10.1007/s11704-016-6108-z> <doi: 10.1103/PhysRevE.72.056130>. This is a robustness measure based on random graph theory. The critical fraction against random attacks is labeled as P_{c}^r. It is defined:

P_{c}^r = 1 - \frac{1}{\frac{\langle k^2 \rangle}{\langle k \rangle} - 1}

where \langle k \rangle is the average nodal degree of the original network, and \langle k^2 \rangle is the average of square of nodal degree.

run

default 10. Replication number of simulation for the sampling method; Only available when remove_strategy = "edge_rand", "node_rand" or "node_hub".

Returns

res_table and res_summary, stored in the object. The res_table is the original simulation result. The Mean and SD in res_summary come from the res_table.

Examples
tmp <- robustness$new(soil_amp_network, remove_strategy = c("edge_rand"), 
  measure = c("Eff"), run = 3, remove_ratio = c(0.1, 0.5, 0.9))


Method plot()

Plot the simulation results.

Usage
robustness$plot(
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  show_point = TRUE,
  point_size = 1,
  point_alpha = 0.6,
  show_errorbar = TRUE,
  errorbar_position = position_dodge(0),
  errorbar_size = 1,
  errorbar_width = 0.1,
  add_fitting = FALSE,
  ...
)
Arguments
color_values

colors used for presentation.

show_point

default TRUE; whether show the point.

point_size

default .3; point size value.

point_alpha

default .6; point alpha value.

show_errorbar

default TRUE; whether show the errorbar by using the SD result.

errorbar_position

default position_dodge(0); Position adjustment, either as a string (such as "identity"), or the result of a call to a position adjustment function.

errorbar_size

default 1; errorbar size.

errorbar_width

default 0.1; errorbar width.

add_fitting

default FALSE; whether add fitted smooth line. FALSE denotes add line segment among points.

...

parameters pass to ggplot2::geom_line (when add_fitting = FALSE) or ggplot2::geom_smooth (when add_fitting = TRUE).

Returns

ggplot.

Examples
\donttest{
tmp$plot(linewidth = 1)
}

Method clone()

The objects of this class are cloneable with this method.

Usage
robustness$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `robustness$new`
## ------------------------------------------------

tmp <- robustness$new(soil_amp_network, remove_strategy = c("edge_rand"), 
  measure = c("Eff"), run = 3, remove_ratio = c(0.1, 0.5, 0.9))


## ------------------------------------------------
## Method `robustness$plot`
## ------------------------------------------------


tmp$plot(linewidth = 1)


meconetcomp documentation built on June 23, 2024, 9:06 a.m.