https://github.com/kwokhing/network-analysis-on-mrt-station
Demo on applying the concept of network analysis on a network of connected railway stations, attempting to identify the important stations (nodes) in this network. Web scraping techniques using rvest package is also briefly discussed upon.
https://github.com/kwokhing/network-analysis-on-mrt-station
betweenness-centrality closeness-centrality data-cleaning degree-centrality eigenvector-centrality gephi graph-analysis igraph r rvest social-network-analysis social-networks web-scraping xpath
Last synced: 8 months ago
JSON representation
Demo on applying the concept of network analysis on a network of connected railway stations, attempting to identify the important stations (nodes) in this network. Web scraping techniques using rvest package is also briefly discussed upon.
- Host: GitHub
- URL: https://github.com/kwokhing/network-analysis-on-mrt-station
- Owner: KwokHing
- License: unlicense
- Created: 2018-01-08T14:18:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T11:56:56.000Z (over 6 years ago)
- Last Synced: 2025-04-06T02:41:18.770Z (about 1 year ago)
- Topics: betweenness-centrality, closeness-centrality, data-cleaning, degree-centrality, eigenvector-centrality, gephi, graph-analysis, igraph, r, rvest, social-network-analysis, social-networks, web-scraping, xpath
- Language: R
- Homepage:
- Size: 1.17 MB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Introduction to basic Network Analysis using railway (Singapore MRT) stations ##
This demo will provide
- a brief introduction to web scraping using Rvest package
- a brief introduction to the concept of graph and network analysis using R igraph package
- a brief introduction on the metrics used to perform network analysis (such as degree, betweeness, closeness and eigenvector centrality)
- investigation into which MRT station is an important node in the Singapore MRT network
## Codes Walkthrough ##
Installing the rvest package to scrape the list of MRT stations from wikipedia
```R
install.packages("rvest")
library(rvest)
```
Installing package into '/home/nbcommon/R'
(as 'lib' is unspecified)
also installing the dependencies 'xml2', 'selectr'
Loading required package: xml2
Before we can scrape the MRT stations data, we would need to ascertain the correct [XPath](https://www.w3schools.com/xml/xpath_intro.asp) to use.
1. navigate to the [wikipedia page](https://en.wikipedia.org/wiki/List_of_Singapore_MRT_stations) and fire up the developer tool (*F12 for windows or right-click > Inspect*)
2. copy the table XPath

Now we are ready to do some real and dirty work, scraping and cleaning the data!
### Data Scraping
```R
url <- "https://en.wikipedia.org/wiki/List_of_Singapore_MRT_stations"
```
```R
mrt_stn <- url %>%
read_html() %>%
#paste the copied xpath: html_nodes(xpath here)
html_nodes(xpath='//*[@id="mw-content-text"]/div/table[2]') %>%
html_table(fill = TRUE)
```
```R
mrt <- mrt_stn[[1]]
```
### Data Cleaning
```R
mrt <- mrt[,c(1:2,5,7:8)]
names(mrt) <- c("Code","Name","Opening","Status","Location")
```
```R
mrt <- subset(mrt,Code != Name)
```
```R
mrt <- mrt[2:nrow(mrt),]
```
```R
mrt$Code <- substr(mrt$Code, 1, 4)
mrt$Code <- iconv(mrt$Code, "ASCII", "UTF-8", sub="")
mrt$Name <- gsub('\\[.\\]',"",mrt$Name)
```
```R
mrt <- mrt[mrt$Name != 'Reserved Station',]
mrt <- mrt[mrt$Name != 'Punggol Coast',]
mrt <- mrt[mrt$Status != 'TBA',]
```
### Generating the MRT network's edgelist
i. preparing the North-South Line (NSL) edgelist
```R
ns_df <- mrt[substr(mrt$Code,1,2) == 'NS',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(ns_df)-1) {
sourceList[i] <- ns_df$Name[i]
targetList[i] <- ns_df$Name[i+1]
}
ns_edgelist <- data.frame(sourceList, targetList, "NSL")
names(ns_edgelist) <- c("source", "target", "network")
```
ii. preparing the East-West Line (EWL) edgelist
```R
ew_df <- mrt[substr(mrt$Code,1,2) == 'EW',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(ew_df)-1) {
sourceList[i] <- ew_df$Name[i]
targetList[i] <- ew_df$Name[i+1]
}
ew_edgelist <- data.frame(sourceList, targetList, "EWL")
names(ew_edgelist) <- c("source", "target", "network")
```
iii. preparing the Changi Airport Branch Line (CAL) edgelist
```R
cg_df <- mrt[substr(mrt$Code,1,2) == 'CG',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(cg_df)-1) {
sourceList[i] <- cg_df$Name[i]
targetList[i] <- cg_df$Name[i+1]
}
cg_edgelist <- data.frame(sourceList, targetList, "CAL")
names(cg_edgelist) <- c("source", "target", "network")
```
iv. preparing the North-East Line (NEL) edgelist
```R
ne_df <- mrt[substr(mrt$Code,1,2) == 'NE',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(ne_df)-1) {
sourceList[i] <- ne_df$Name[i]
targetList[i] <- ne_df$Name[i+1]
}
ne_edgelist <- data.frame(sourceList, targetList, "NEL")
names(ne_edgelist) <- c("source", "target", "network")
```
v. preparing the Circle Line (CCL) edgelist
```R
cc_df <- mrt[substr(mrt$Code,1,2) == 'CC',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(cc_df)-1) {
sourceList[i] <- cc_df$Name[i]
targetList[i] <- cc_df$Name[i+1]
}
cc_edgelist <- data.frame(sourceList, targetList, "CCL")
names(cc_edgelist) <- c("source", "target", "network")
```
vi. preparing the Downtown Line (DTL) edgelist
```R
dt_df <- mrt[substr(mrt$Code,1,2) == 'DT',]
sourceList <- ""
targetList <- ""
for (i in 1:nrow(dt_df)-1) {
sourceList[i] <- dt_df$Name[i]
targetList[i] <- dt_df$Name[i+1]
}
dt_edgelist <- data.frame(sourceList, targetList, "DTL")
names(dt_edgelist) <- c("source", "target", "network")
```
```R
mrt_edgelist <- rbind(ns_edgelist,ew_edgelist,cg_edgelist,ne_edgelist,cc_edgelist,dt_edgelist)
```
```R
mrt_edgelist
```
sourcetargetnetwork
Jurong East Bukit Batok NSL
Bukit Batok Bukit Gombak NSL
Bukit Gombak Choa Chu Kang NSL
Choa Chu Kang Yew Tee NSL
Yew Tee Kranji NSL
Kranji Marsiling NSL
Marsiling Woodlands NSL
Woodlands Admiralty NSL
Admiralty Sembawang NSL
Sembawang Yishun NSL
Yishun Khatib NSL
Khatib Yio Chu Kang NSL
Yio Chu Kang Ang Mo Kio NSL
Ang Mo Kio Bishan NSL
Bishan Braddell NSL
Braddell Toa Payoh NSL
Toa Payoh Novena NSL
Novena Newton NSL
Newton Orchard NSL
Orchard Somerset NSL
Somerset Dhoby Ghaut NSL
Dhoby Ghaut City Hall NSL
City Hall Raffles Place NSL
Raffles Place Marina Bay NSL
Marina Bay Marina South PierNSL
Pasir Ris Tampines EWL
Tampines Simei EWL
Simei Tanah Merah EWL
Tanah Merah Bedok EWL
Bedok Kembangan EWL
.........
Beauty World King Albert ParkDTL
King Albert ParkSixth Avenue DTL
Sixth Avenue Tan Kah Kee DTL
Tan Kah Kee Botanic Gardens DTL
Botanic Gardens Stevens DTL
Stevens Newton DTL
Newton Little India DTL
Little India Rochor DTL
Rochor Bugis DTL
Bugis Promenade DTL
Promenade Bayfront DTL
Bayfront Downtown DTL
Downtown Telok Ayer DTL
Telok Ayer Chinatown DTL
Chinatown Fort Canning DTL
Fort Canning Bencoolen DTL
Bencoolen Jalan Besar DTL
Jalan Besar Bendemeer DTL
Bendemeer Geylang Bahru DTL
Geylang Bahru Mattar DTL
Mattar MacPherson DTL
MacPherson Ubi DTL
Ubi Kaki Bukit DTL
Kaki Bukit Bedok North DTL
Bedok North Bedok Reservoir DTL
Bedok Reservoir Tampines West DTL
Tampines West Tampines DTL
Tampines Tampines East DTL
Tampines East Upper Changi DTL
Upper Changi Expo DTL
```R
mrt_edgelist$target <- as.character(mrt_edgelist$target)
mrt_edgelist$source <- as.character(mrt_edgelist$source)
mrt_edgelist$network <- as.character(mrt_edgelist$network)
```
Closing the loop for the graph network
```R
mrt_edgelist[nrow(mrt_edgelist)+1,] <- c("Bayfront","Marina Bay","CEL")
mrt_edgelist[nrow(mrt_edgelist)+1,] <- c("Bayfront","Promenade","CCL")
mrt_edgelist[nrow(mrt_edgelist)+1,] <- c("Tanah Merah","Expo","CAL")
```
Specifying this network to be a undirected graph network
```R
mrt_edgelist$type <- "undirected"
```
Exporting the mrt edgelist to csv
```R
write.csv(mrt_edgelist, file="mrt_edgelist.csv", row.names=F)
```
### Generating the MRT network's nodelist
```R
mrt_node <- mrt[substr(mrt$Code,1,2) != 'TE',]
names(mrt_node)[2] <- "id"
mrt_node$label <- mrt_node$id
# removing duplicated mrt names/nodes (nodes in a network should be unique)
mrt_nodes <- unique(mrt_node)
mrt_nodes <- mrt_nodes[!duplicated(mrt_nodes$id),]
mrt_nodes$Code <- substr(mrt_nodes$Code, 1, 2)
```
Exporting the mrt nodes to csv
```R
write.csv(mrt_nodes, file="mrt_nodes.csv", row.names=F)
```
### Visualisation of the MRT network using Gephi

### Visualisation of the MRT network using R igraph package
Installing the igraph package to do graph network analysis and plotting
```R
install.packages("igraph")
library(igraph)
```
Installing package into '/home/nbcommon/R'
(as 'lib' is unspecified)
Attaching package: 'igraph'
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
```R
# renaming for igraph edgelist format
names(mrt_edgelist) <- c("from","to","network","type")
# rearranging for igraph nodelist format
mrt_nodes <- mrt_nodes[c(2,6,1,3,4,5)]
```
Setting up the graph network
```R
g = graph.data.frame(mrt_edgelist, mrt_nodes, directed=F)
# Removing self loops
# g = simplify(g, remove.loops = T)
```
Checking if multiple edges exists in the graph network
```R
any_multiple(g)
which_multiple(g)
#count_multiple(g)
#which_multiple(simplify(g))
#all(count_multiple(simplify(g)) == 1)
E(g)[38]
E(g)[135]
```
TRUE
+ 1/136 edge from d7df987 (vertex names):
[1] City Hall--Raffles Place
+ 1/136 edge from d7df987 (vertex names):
[1] Promenade--Bayfront
Removing multiple edges to create a simplified graph
```R
simple_g <- g
```
```R
simple_g <- delete_edges(simple_g,c(38,135))
```
```R
any_multiple(simple_g)
```
FALSE
Displaying descriptive statistics of the graph network
```R
V(simple_g)
```
+ 119/119 vertices, named, from 24e1b48:
[1] Jurong East Bukit Batok Bukit Gombak Choa Chu Kang
[5] Yew Tee Kranji Marsiling Woodlands
[9] Admiralty Sembawang Yishun Khatib
[13] Yio Chu Kang Ang Mo Kio Bishan Braddell
[17] Toa Payoh Novena Newton Orchard
[21] Somerset Dhoby Ghaut City Hall Raffles Place
[25] Marina Bay Marina South Pier Pasir Ris Tampines
[29] Simei Tanah Merah Bedok Kembangan
[33] Eunos Paya Lebar Aljunied Kallang
[37] Lavender Bugis Tanjong Pagar Outram Park
+ ... omitted several vertices
```R
E(simple_g)
```
+ 134/134 edges from 24e1b48 (vertex names):
[1] Jurong East --Bukit Batok Bukit Batok --Bukit Gombak
[3] Bukit Gombak --Choa Chu Kang Choa Chu Kang--Yew Tee
[5] Yew Tee --Kranji Kranji --Marsiling
[7] Marsiling --Woodlands Woodlands --Admiralty
[9] Admiralty --Sembawang Sembawang --Yishun
[11] Yishun --Khatib Khatib --Yio Chu Kang
[13] Yio Chu Kang --Ang Mo Kio Ang Mo Kio --Bishan
[15] Bishan --Braddell Braddell --Toa Payoh
[17] Toa Payoh --Novena Novena --Newton
[19] Newton --Orchard Orchard --Somerset
+ ... omitted several edges
```R
# Network Size (num of nodes and edges)
summary(simple_g)
# Network Density
graph.density(simple_g,loop=FALSE)
# greatest distance between any pair of vertices
diameter(simple_g)
# Average Path Length
mean_distance(simple_g, directed=F)
```
IGRAPH 24e1b48 UN-- 119 134 --
+ attr: name (v/c), label (v/c), Code (v/c), Opening (v/c), Status
| (v/c), Location (v/c), network (e/c), type (e/c)
0.0190856003418316
30
10.0371741917106
```R
# Length of all paths in the graph
distances(simple_g)
```
Jurong EastBukit BatokBukit GombakChoa Chu KangYew TeeKranjiMarsilingWoodlandsAdmiraltySembawang...BendemeerGeylang BahruMattarUbiKaki BukitBedok NorthBedok ReservoirTampines WestTampines EastUpper Changi
Jurong East 0 1 2 3 4 5 6 7 8 9 ...13 14 15 15 16 17 18 19 21 21
Bukit Batok 1 0 1 2 3 4 5 6 7 8 ...14 15 16 16 17 18 19 20 22 22
Bukit Gombak 2 1 0 1 2 3 4 5 6 7 ...15 16 17 17 18 19 20 21 23 23
Choa Chu Kang 3 2 1 0 1 2 3 4 5 6 ...16 17 17 17 18 19 20 21 23 23
Yew Tee 4 3 2 1 0 1 2 3 4 5 ...17 17 16 16 17 18 19 20 22 22
Kranji 5 4 3 2 1 0 1 2 3 4 ...17 16 15 15 16 17 18 19 21 21
Marsiling 6 5 4 3 2 1 0 1 2 3 ...16 15 14 14 15 16 17 18 20 20
Woodlands 7 6 5 4 3 2 1 0 1 2 ...15 14 13 13 14 15 16 17 19 19
Admiralty 8 7 6 5 4 3 2 1 0 1 ...14 13 12 12 13 14 15 16 18 18
Sembawang 9 8 7 6 5 4 3 2 1 0 ...13 12 11 11 12 13 14 15 17 17
Yishun10 9 8 7 6 5 4 3 2 1 ...12 11 10 10 11 12 13 14 16 16
Khatib11 10 9 8 7 6 5 4 3 2 ...11 10 9 9 10 11 12 13 15 15
Yio Chu Kang11 11 10 9 8 7 6 5 4 3 ...10 9 8 8 9 10 11 12 14 14
Ang Mo Kio10 11 11 10 9 8 7 6 5 4 ... 9 8 7 7 8 9 10 11 13 13
Bishan 9 10 11 11 10 9 8 7 6 5 ... 8 7 6 6 7 8 9 10 12 12
Braddell10 11 12 12 11 10 9 8 7 6 ... 9 8 7 7 8 9 10 11 13 13
Toa Payoh10 11 12 13 12 11 10 9 8 7 ...10 9 8 8 9 10 11 12 14 14
Novena 9 10 11 12 13 12 11 10 9 8 ... 9 10 9 9 10 11 12 13 15 14
Newton 8 9 10 11 12 13 12 11 10 9 ... 8 9 9 9 10 11 12 13 14 13
Orchard 9 10 11 12 13 14 13 12 11 10 ... 8 9 10 10 11 12 13 14 15 14
Somerset10 11 12 13 14 15 14 13 12 11 ... 7 8 9 9 10 11 12 13 14 13
Dhoby Ghaut10 11 12 13 14 15 14 13 12 11 ... 6 7 8 8 9 10 11 12 13 12
City Hall11 12 13 14 15 16 15 14 13 12 ... 7 8 7 7 8 9 10 11 12 11
Raffles Place10 11 12 13 14 15 16 15 14 13 ... 7 8 8 8 9 10 11 12 13 12
Marina Bay11 12 13 14 15 16 17 16 15 14 ... 8 9 9 9 10 11 12 13 14 13
Marina South Pier12 13 14 15 16 17 18 17 16 15 ... 9 10 10 10 11 12 13 14 15 14
Pasir Ris21 22 23 23 22 21 20 19 18 17 ...10 9 8 6 5 4 3 2 2 3
Tampines20 21 22 22 21 20 19 18 17 16 ... 9 8 7 5 4 3 2 1 1 2
Simei20 21 22 22 21 20 19 18 17 16 ... 9 8 7 6 5 4 3 2 2 3
Tanah Merah19 20 21 21 20 19 18 17 16 15 ... 8 7 6 6 6 5 4 3 3 2
................................. ..............................
Kent Ridge 5 6 7 8 9 10 11 12 13 13 ...11 12 13 14 15 16 17 18 20 20
Haw Par Villa 6 7 8 9 10 11 12 13 14 14 ...10 11 12 14 15 16 17 18 20 19
Pasir Panjang 7 8 9 10 11 12 13 14 15 15 ... 9 10 11 13 14 15 16 17 19 18
Labrador Park 8 9 10 11 12 13 14 15 16 16 ... 8 9 10 12 13 14 15 16 18 17
Telok Blangah 9 10 11 12 13 14 15 16 17 16 ... 7 8 9 11 12 13 14 15 17 16
Bayfront12 13 14 15 16 17 17 16 15 14 ... 7 8 8 8 9 10 11 12 13 12
Bukit Panjang13 14 15 16 17 18 18 17 16 15 ...17 17 16 16 17 18 19 20 22 22
Cashew12 13 14 15 16 17 17 16 15 14 ...16 16 15 15 16 17 18 19 21 21
Hillview11 12 13 14 15 16 16 15 14 13 ...15 15 14 14 15 16 17 18 20 20
Beauty World10 11 12 13 14 15 15 14 13 12 ...14 14 13 13 14 15 16 17 19 19
King Albert Park 9 10 11 12 13 14 14 13 12 11 ...13 13 12 12 13 14 15 16 18 18
Sixth Avenue 8 9 10 11 12 13 13 12 11 10 ...12 12 11 11 12 13 14 15 17 17
Tan Kah Kee 7 8 9 10 11 12 12 11 10 9 ...11 11 10 10 11 12 13 14 16 16
Stevens 7 8 9 10 11 12 12 11 10 9 ... 9 10 10 10 11 12 13 14 15 14
Rochor10 11 12 13 14 15 14 13 12 11 ... 8 8 7 7 8 9 10 11 12 11
Downtown11 12 13 14 15 16 17 17 16 15 ... 6 7 8 9 10 11 12 13 14 13
Telok Ayer10 11 12 13 14 15 16 16 15 14 ... 5 6 7 9 10 11 12 13 15 14
Fort Canning10 11 12 13 14 15 16 16 15 14 ... 3 4 5 7 8 9 10 11 13 13
Bencoolen11 12 13 14 15 16 17 17 16 15 ... 2 3 4 6 7 8 9 10 12 12
Jalan Besar12 13 14 15 16 17 17 16 15 14 ... 1 2 3 5 6 7 8 9 11 11
Bendemeer13 14 15 16 17 17 16 15 14 13 ... 0 1 2 4 5 6 7 8 10 10
Geylang Bahru14 15 16 17 17 16 15 14 13 12 ... 1 0 1 3 4 5 6 7 9 9
Mattar15 16 17 17 16 15 14 13 12 11 ... 2 1 0 2 3 4 5 6 8 8
Ubi15 16 17 17 16 15 14 13 12 11 ... 4 3 2 0 1 2 3 4 6 7
Kaki Bukit16 17 18 18 17 16 15 14 13 12 ... 5 4 3 1 0 1 2 3 5 6
Bedok North17 18 19 19 18 17 16 15 14 13 ... 6 5 4 2 1 0 1 2 4 5
Bedok Reservoir18 19 20 20 19 18 17 16 15 14 ... 7 6 5 3 2 1 0 1 3 4
Tampines West19 20 21 21 20 19 18 17 16 15 ... 8 7 6 4 3 2 1 0 2 3
Tampines East21 22 23 23 22 21 20 19 18 17 ...10 9 8 6 5 4 3 2 0 1
Upper Changi21 22 23 23 22 21 20 19 18 17 ...10 9 8 7 6 5 4 3 1 0
In graph theory and network analysis, indicators of centrality identify the most important vertices within a graph. Applications include identifying the most influential person(s) in a social network, key infrastructure nodes in the Internet or urban networks, and super-spreaders of disease. In this scenario, we could identify the important stations in the MRT network using different centrality measures.
Generation of graph attributes: **Degree Centrality** (_in-degree, out-degree and total degree_)
Since this is an undirected network, we will use the _total degree_ centrality measure.
[_in-degree_ and _out-degree_ will be relevant if it is a directed network graph]
**Degree centrality** measures how connected an entity is by counting the number of direct links each entity has to others in the network.
```R
V(simple_g)$degree=degree(simple_g, mode="all")
```
**Betweenness centrality** measures the number of paths that pass through each entity.
```R
V(simple_g)$betweenness=betweenness(simple_g,normalized=T)
```
Generation of graph attributes: **Closeness Centrality**
Closeness centrality (or closeness) of a node is a measure of centrality in a network, calculated as the sum of the length of the shortest paths between the node and all other nodes in the graph. Thus the more central a node is, the closer it is to all other nodes
**Closeness centrality** measures the proximity of an entity to the other entities in the social network.
```R
V(simple_g)$closeness=closeness(simple_g, normalized=T)
```
Generation of graph attributes: **Eigenvector**
**Eigenvector** measures how connected an entity is and how much direct influence it might have over other connected entities in the network.
```R
V(simple_g)$eigen=evcent(simple_g)$vector
```
**Coreness** is a measure that can help identify tightly interlinked groups within a network. A k-core is a maximal group of entities, all of which are connected to at least k other entities in the group.
```R
V(simple_g)$coreness=coreness(simple_g)
```
Specify graph layout to use
```R
glay = layout_with_lgl(simple_g)
```
Installing the plyr package for data mapping / transformation
```R
install.packages("plyr")
library(plyr)
```
Installing package into '/home/nbcommon/R'
(as 'lib' is unspecified)
```R
# Generate node colors based on network:
E(simple_g)$color <- mapvalues(E(simple_g)$network, c("NSL","EWL","CAL","NEL","CCL","DTL","CEL"), c("#D42E12","#009645","#009645","#9900AA","#FA9E0D","#FA9E0D","#005EC4"))
```
```R
# plot degree graph
plot(simple_g, layout=glay, edge.color=E(simple_g)$color, edge.width=3, edge.curve=1,
vertex.label.cex=.7, vertex.color="white", vertex.frame.color="black",
vertex.label.font=1.5, vertex.label=V(simple_g)$label, vertex.label.color="grey40",
vertex.size=V(simple_g)$degree*3.5)
```

```R
V(simple_g)$name[degree(simple_g)==max(degree(simple_g))]
```
'Dhoby Ghaut'
```R
# plot closeness graph
plot(simple_g, layout=glay, edge.color=E(simple_g)$color, edge.width=3, edge.curve=1,
vertex.label.cex=.7, vertex.color="white", vertex.frame.color="black",
vertex.label.font=.7, vertex.label=V(simple_g)$label, vertex.label.color="grey40",
vertex.size=V(simple_g)$closeness*90)
```

```R
V(simple_g)$name[closeness(simple_g)==max(closeness(simple_g))]
```
'Little India'
```R
# plot betweenness graph
plot(simple_g, layout=glay, edge.color=E(simple_g)$color, edge.width=3, edge.curve=1,
vertex.label.cex=.7, vertex.color="white", vertex.frame.color="black",
vertex.label.font=1, vertex.label=V(simple_g)$label, vertex.label.color="grey40",
vertex.size=V(simple_g)$betweenness*60)
```

```R
V(simple_g)$name[betweenness(simple_g)==max(betweenness(simple_g))]
```
'Botanic Gardens'
```R
# plot eigenvector graph
plot(simple_g, layout=glay, edge.color=E(simple_g)$color, edge.width=3, edge.curve=1,
vertex.label.cex=.7, vertex.color="white", vertex.frame.color="black",
vertex.label.font=1, vertex.label=V(simple_g)$label, vertex.label.color="grey40",
vertex.size=V(simple_g)$eigen*20)
```

```R
V(simple_g)$name[which.max(V(simple_g)$eigen)]
```
'Dhoby Ghaut'
```R
attr = data.frame(row.names=V(simple_g)$name,degree=V(simple_g)$degree,
coreness=V(simple_g)$coreness,betweenness=V(simple_g)$betweenness,
closeness=V(simple_g)$closeness,eigen=V(simple_g)$eigen)
```
```R
table(attr$degree)
table(attr$coreness)
table(attr$betweenness)
table(attr$closeness)
table(attr$eigen)
```
1 2 3 4 5
6 92 7 13 1
1 2
24 95
0 0.00195567144719687 0.00402964894490318 0.0047008547008547
6 1 1 1
0.00582114056690328 0.0068810662031001 0.0123293530073191 0.0127891255009899
1 1 1 1
0.0160534067313728 0.0169491525423729 0.0175975938687803 0.0226816498002939
1 3 1 1
0.0227057938922346 0.0232110952449936 0.0251684912701862 0.0258203817525851
1 1 1 1
0.0267399267399267 0.0270655270655271 0.0278960838282872 0.0288625373371136
1 1 1 1
0.0309630733359547 0.0317977690859047 0.033391279153991 0.0336085759814573
1 1 1 3
0.0344398225754158 0.0345308802935922 0.0345767540682795 0.0346226278429668
1 1 1 1
0.0353928243758752 0.0373026220483848 0.0386443437290895 0.0401395528514173
1 1 1 1
0.0412863972186006 0.0418948283355063 0.0421676565744362 0.0422087015307354
1 1 1 1
0.0424798051916696 0.0436163020908784 0.0445023902651021 0.0465739533536144
1 1 1 1
0.0471775556521319 0.0475807619875416 0.0482295482295482 0.0484378772514366
1 1 1 1
0.0486262011685741 0.0490656236418948 0.0493988121106765 0.0499782703172534
1 1 1 3
0.0505456564778599 0.052923849534019 0.056188130764402 0.0593220338983051
1 1 1 1
0.0604809503114588 0.062344874209281 0.066058235549761 0.066597338631237
1 1 3 1
0.0671326476411222 0.0689813952525817 0.0691848954560819 0.0705852527886426
1 1 1 1
0.0706214689265537 0.0744724515910957 0.0762518711671254 0.0766843953284631
2 1 1 1
0.0799845477811579 0.0818484716789802 0.0819209039548023 0.0904485972282583
1 2 1 1
0.0926601960500266 0.0941285017556204 0.0945241199478488 0.096830225643785
1 1 1 1
0.0973489787049109 0.0997275166766692 0.105159937363327 0.106567193007871
2 1 1 1
0.108431116905693 0.112559756627553 0.120474189965715 0.124850479087767
1 1 1 1
0.127480805446907 0.132674199623352 0.137474734932362 0.142346667770397
1 1 1 1
0.144993894993895 0.147746321475135 0.15777267302691 0.168727537371605
1 1 1 1
0.171709332726282 0.189225871429261 0.190974248601367 0.19911632623497
1 1 1 1
0.202158481819499 0.202221601374144 0.205202361982023 0.210415761263219
1 1 1 1
0.211503969978546 0.222513330987907 0.226112180349468 0.249501596959224
1 1 1 1
0.259219593965357 0.277175900057256 0.314647530749226
1 1 1
0.053393665158371 0.0563784042044912 0.0596562184024267 0.0632707774798928
1 1 1 1
0.0672748004561003 0.0708708708708709 0.0711271850512357 0.0717325227963526
1 1 1 1
0.0718198417528911 0.0721271393643032 0.0727945712523134 0.0762273901808786
1 1 1 1
0.0767230169050715 0.077124183006536 0.0773263433813893 0.0776826859776168
1 1 1 1
0.077990746860542 0.0781456953642384 0.0784053156146179 0.0793544048419637
1 1 1 1
0.0794078061911171 0.0798376184032476 0.0809327846364883 0.0823447313328681
1 1 1 1
0.0830401125967628 0.0836286321757619 0.0838068181818182 0.0841654778887304
1 1 1 1
0.085383502170767 0.0861313868613139 0.0885221305326332 0.0887218045112782
1 1 1 1
0.0890566037735849 0.0899390243902439 0.0909090909090909 0.0917573872472784
1 1 1 1
0.0940239043824701 0.0960130187144019 0.0970394736842105 0.0972794723825227
2 1 1 1
0.0973597359735974 0.0988274706867672 0.0990764063811923 0.0991596638655462
1 1 1 1
0.0994102780117944 0.100254885301614 0.101636520241171 0.101811906816221
1 1 1 1
0.10251954821894 0.103327495621716 0.105357142857143 0.105545617173524
1 1 1 1
0.106594399277326 0.107175295186194 0.1073703366697 0.107468123861566
1 1 1 1
0.108058608058608 0.108256880733945 0.10865561694291 0.109158186864015
1 1 1 1
0.109461966604824 0.109767441860465 0.109869646182495 0.109972041006524
1 1 1 1
0.110383536014967 0.111848341232227 0.112060778727445 0.112595419847328
1 1 1 2
0.112702960840497 0.113026819923372 0.113461538461538 0.114451988360815
1 1 1 1
0.115234375 0.11545988258317 0.115572967678746 0.116370808678501
1 2 1 1
0.117647058823529 0.118592964824121 0.118712273641851 0.119071644803229
1 1 2 1
0.119312436804853 0.119433198380567 0.119918699186992 0.121025641025641
1 2 1 1
0.121274409044193 0.121524201853759 0.121900826446281 0.122026887280248
1 2 1 1
0.122279792746114 0.123044838373306 0.123430962343096 0.124341412012645
1 1 1 1
0.124604012671595 0.124867724867725 0.12566560170394 0.125933831376734
1 1 1 1
0.126473740621651 0.127292340884574 0.127843986998917 0.127982646420824
1 1 1 2
0.128121606948969 0.12910284463895 0.130099228224917 0.131403118040089
1 1 1 2
0.131843575418994 0.133182844243792 0.134090909090909 0.135476463834673
1 1 1 1
0.136258660508083 0.138173302107728 0.140979689366786
1 1 1
2.51858362053298e-07 7.39028698759823e-07 1.91667562290336e-06
1 1 1
4.88507796089859e-06 1.24176223479958e-05 2.10200818492998e-05
1 1 1
2.67431016136541e-05 3.15519861450127e-05 3.493618354964e-05
1 1 1
5.74522762701692e-05 8.01654591480061e-05 8.14932595885658e-05
1 1 1
0.000141839273885244 0.000167809921265858 0.000177714640335611
1 1 1
0.000185105863472294 0.000203677745616489 0.000204189716771217
1 1 1
0.000223321313009527 0.000287174882385132 0.000321189495444625
1 1 1
0.000358747103161553 0.000417817517967914 0.000492405122926692
1 1 1
0.000517486721433531 0.000517661199389077 0.000521468567890903
1 1 1
0.000543156654683785 0.000647439641568565 0.000655292355512262
1 1 1
0.000704534547681859 0.000910833357740738 0.00127705581286622
1 1 1
0.00131478499340561 0.00137831538939482 0.00140868023272799
1 1 1
0.00164950018256149 0.00231391377469838 0.00274166271824377
1 1 1
0.00282282937525379 0.00325486333280614 0.0035903377056515
1 1 1
0.00378373757664514 0.00380690651505764 0.00413559846730773
1 1 1
0.00587889032532363 0.00666655321918628 0.0069682511646331
1 1 1
0.00729572527509893 0.00738687889451853 0.007573376213864
1 1 1
0.00827369879931538 0.00912645777319788 0.010485598006559
1 1 1
0.0105653985966293 0.0116571804822862 0.0124409387540652
1 1 1
0.012822558121519 0.0133160285498551 0.0149365306059223
1 1 1
0.016820023102403 0.017624129573429 0.0178684329563004
1 1 1
0.0200011387088744 0.0208359090163346 0.021022674274045
1 1 1
0.0231894529515193 0.0234287025398688 0.0246279983079351
1 1 1
0.0256415713329211 0.0266323211910227 0.0281642727572974
1 1 1
0.0324649884818062 0.0379494133507986 0.0399540168190206
1 1 1
0.0426884877753544 0.0431176419956824 0.0450445140766606
1 1 1
0.0458668393248469 0.0520506817733822 0.053413193322856
1 1 1
0.0536443324331427 0.0546418749796778 0.0573126934639011
1 1 1
0.0581815090184332 0.0885708045661908 0.0890729109251433
1 1 1
0.105253358095607 0.114305811115643 0.114586056646666
1 1 1
0.114720227435284 0.127090890274223 0.13570780879659
1 1 1
0.14729346265851 0.188118280674737 0.19157545406345
1 1 1
0.216775918415613 0.221412875690504 0.232840042447464
1 1 1
0.249100008151929 0.282979552890921 0.290363348277626
1 1 1
0.308845224052014 0.320872474237074 0.342513847439296
1 1 1
0.347566516922269 0.36042054487175 0.374022111837471
1 1 1
0.440571504738262 0.457523962582117 0.459245894439935
1 1 1
0.46826186745292 0.52144365496715 0.54751538121932
1 1 1
0.560619511605635 0.715627468790695 0.734824970607291
1 1 1
0.814446111403723 1
1 1
```R
attr
```
degreecorenessbetweennessclosenesseigen
Jurong East3 2 0.202158482 0.09601302 1.314785e-03
Bukit Batok2 2 0.060480950 0.08905660 5.176612e-04
Bukit Gombak2 2 0.046573953 0.08304011 2.041897e-04
Choa Chu Kang2 2 0.037302622 0.07940781 8.149326e-05
Yew Tee2 2 0.033391279 0.07799075 3.493618e-05
Kranji2 2 0.031797769 0.07712418 2.102008e-05
Marsiling2 2 0.034622628 0.07840532 2.674310e-05
Woodlands2 2 0.041286397 0.08093278 5.745228e-05
Admiralty2 2 0.049398812 0.08416548 1.418393e-04
Sembawang2 2 0.059322034 0.08852213 3.587471e-04
Yishun2 2 0.070621469 0.09402390 9.108334e-04
Khatib2 2 0.081920904 0.10025489 2.313914e-03
Yio Chu Kang2 2 0.094524120 0.10825688 5.878890e-03
Ang Mo Kio2 2 0.108431117 0.11871227 1.493653e-02
Bishan4 2 0.259219594 0.13140312 3.794941e-02
Braddell2 2 0.048626201 0.12434141 4.311764e-02
Toa Payoh2 2 0.047177556 0.12304484 8.857080e-02
Novena2 2 0.052923850 0.12812161 2.167759e-01
Newton4 2 0.202221601 0.13817330 5.475154e-01
Orchard2 2 0.006881066 0.12486772 3.425138e-01
Somerset2 2 0.005821141 0.12566560 4.575240e-01
Dhoby Ghaut5 2 0.132674200 0.13547646 1.000000e+00
City Hall3 2 0.076684395 0.13009923 7.348250e-01
Raffles Place3 2 0.068981395 0.12460401 4.405715e-01
Marina Bay3 2 0.023211095 0.11302682 3.088452e-01
Marina South Pier1 1 0.000000000 0.10163652 1.052534e-01
Pasir Ris1 1 0.000000000 0.07087087 1.777146e-04
Tampines4 2 0.034576754 0.07622739 5.214686e-04
Simei2 2 0.016053407 0.07814570 6.474396e-04
Tanah Merah3 2 0.079984548 0.08380682 1.378315e-03
..................
Kent Ridge2 2 0.027065527 0.09907641 0.0037837376
Haw Par Villa2 2 0.022681650 0.09727947 0.0038069065
Pasir Panjang2 2 0.022705794 0.09735974 0.0073868789
Labrador Park2 2 0.025168491 0.09882747 0.0178684330
Telok Blangah2 2 0.030963073 0.10181191 0.0450445141
Bayfront3 2 0.026739927 0.11346154 0.3604205449
Bukit Panjang1 1 0.000000000 0.07181984 0.0001678099
Cashew2 1 0.016949153 0.07732634 0.0004924051
Hillview2 1 0.033608576 0.08362863 0.0012770558
Beauty World2 1 0.049978270 0.09090909 0.0032548633
King Albert Park2 1 0.066058236 0.09941028 0.0082736988
Sixth Avenue2 1 0.081848472 0.10946197 0.0210226743
Tan Kah Kee2 1 0.097348979 0.12152420 0.0534131933
Stevens2 2 0.142346668 0.13409091 0.2328400424
Rochor2 2 0.094128502 0.13318284 0.5214436550
Downtown2 2 0.012329353 0.10976744 0.1881182807
Telok Ayer2 2 0.017597594 0.11545988 0.1915754541
Fort Canning2 2 0.056188131 0.11764706 0.1472934627
Bencoolen2 2 0.049065624 0.11206078 0.0581815090
Jalan Besar2 2 0.044502390 0.10915819 0.0234287025
Bendemeer2 2 0.041894828 0.10737034 0.0105653986
Geylang Bahru2 2 0.042208702 0.10746812 0.0075733762
Mattar2 2 0.047580762 0.11038354 0.0116571805
Ubi2 2 0.090448597 0.10805861 0.0104855980
Kaki Bukit2 2 0.076251871 0.09915966 0.0041355985
Bedok North2 2 0.062344874 0.09175739 0.0016495002
Bedok Reservoir2 2 0.048437877 0.08538350 0.0007045345
Tampines West2 2 0.034530880 0.07983762 0.0004178175
Tampines East2 2 0.001955671 0.07112719 0.0002871749
Upper Changi2 2 0.004029649 0.07279457 0.0003211895
### Summary ###
From the results obtained from the different centrality measures applied to the MRT network, we could often see that the station 'Dhoby Ghaut' frequently appears as one of the significant nodes suggesting that it could likely be the most important node in the MRT network. The consequences of removing such a node might breaks the network into different smaller networks and reduce connectivity among the network, seriously impairing the connectivity and coverage of the MRT services.