Description Usage Arguments Value Examples
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.
1 |
g |
igraph; a supply network where every node has a 'type' attribute, which can be "P" (producer), "I" (intermediary), or "D" (distributor). |
igraph; a supply network in which every producer has a path towards a distributor, and and every distributor have a producer upstream.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.