In this workshop we are going to compare centrality and power on the European natural gas pipeline network. Data comes from the website of the International Energy Agency. The network is depicted here: European natural gas pipeline network

Load libraries and user-defined functions:

library(igraph)
library(lpSolve)
library(lpSolveAPI)
source("fun.R")

Read the dataset

# read states and abbreviations
dfstates = read.table("states.txt", header = TRUE)
states = as.vector(dfstates[,"State"])
abb.states = as.vector(dfstates[,"Abbreviation"])

# read CSV dataset
df = read.table("IEA.csv", header = TRUE, sep = ";")
entry = df[,"Entry"]
exit = df[,"Exit"]

Tidy the dataset

The original data corresponds to a directed, weighted multigraph, with edge weights corresponding to the maximum flow of the pipeline. We will create four networks from the original data.

# create directed weighted graph (dwg)
el = cbind(as.vector(exit), as.vector(entry))
dwg = graph_from_edgelist(el, directed = TRUE)
E(dwg)$weight = df[,"Maxflow"]

# remove Liquefied Natural Gas (LNG) node
dwg = delete_vertices(dwg, 1)

# simplify network (we sum edge weights of multiple edges)
dwg = simplify(dwg, edge.attr.comb="sum")

# create directed unweighted graph (dug)
dug = dwg
dug = delete_edge_attr(dug, "weight")

# create undirected weighted graph (uwg)
# If edges are reciprocal, edge weightes are summed
uwg = as.undirected(dwg, mode = "collapse", edge.attr.comb="sum")

# create undirected unweighted graph (uug)
uug = uwg
uug = delete_edge_attr(uug, "weight")

We ask to perform the following analyses:

  1. on the undirected unweighted network, compute and compare Katz centrality and power. In particular, identify powerful contries that are not central and central countries that are not powerful. Moreover, plot the network with node size proportional to power and centrality and visually compare the two graphs;

  2. on the undirected weighted network, plot the network with edge with proportional to the edge weight (pipeline maxflow). Compute and compare power and centrality. Moreover, plot the network with node size proportional to power and centrality and visually compare the two graphs;

  3. on the directed weighted network, plot the network with edge with proportional to the edge weight (pipeline maxflow). Compute centrality and strength on both the original graph (where edge direction indicates the flow of energy or importations) and the inverted one (where edge direction indicates the flow of money or exportations). Identify exporters that are not importers and importers that are not exporters.