applyCascadingFailures: Apply cascading failures to a supply network

Description Usage Arguments Value Examples

View source: R/robustness.R

Description

The deletion of a vertex or an edge in a supply network can cause other disruptions (cascading failures). This function clean the graph from producers and intermeidaries without customers, and intermediaries or distributors without suppliers. Process is embedded in a while loop to clean all the graph.

Usage

1

Arguments

g

igraph; a supply network where every node has a 'type' attribute, which can be "P" (producer), "I" (intermediary), or "D" (distributor).

Value

igraph; a supply network in which every producer has a path towards a distributor, and and every distributor have a producer upstream.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Generate a theoretical supply network, define producers (P), inter. (I)
## and distributors (D) vertices.
library(igraph)
g = make_tree(10)
V(g)[!degree(g, mode="in")]$type = "P"
V(g)[degree(g, mode="in") & degree(g, mode="in")]$type = "I"
V(g)[!degree(g, mode="out")]$type = "D"
V(g)$color = c("green","red","yellow")[factor(V(g)$type, levels=c("P","I","D"))]
plot(g)
## Delete vertex with highest betweenness
g = delete_vertices(g, V(g)[which.max(betweenness(g))])
plot(g)
## Some vertices are not supplied by any producer: delete them
g = applyCascadingFailures(g)
plot(g)

MiloMonnier/supplynet documentation built on Feb. 16, 2021, 8:03 p.m.