Understanding a Cocaine Trafficking Organization: Mangai Natarajan
o Background: The purpose of the network visualization is to deduce differences in the connectivity of the drug trafficking network so that strategic targeting of key actors can occur. Removal of these key players can be used to disrupt the network resulting in the impairment of the network. Multiple actors may need to be removed so that the network cannot continue functioning.
o Data: The dataset is from a case study of cocaine trafficking organization that was prosecuted in New York City in 1996. The narcotic network was reported to be transporting two to 10 million dollars worth of illegal narcotics on a weekly basis and selling hundreds of kilograms of cocaine each month. The individuals were mostly of Colombian origin and associated to a drug cartel. The data is from wiretap surveillance that resulted in almost 600 pages of the transcripts from 151 telephone conversations. The conversations were translated to English from Spanish. These 600 pages of transcribed words constitute less than 10% of the wiretap data during the investigation of the narcotic network. These wiretap transcripts were taken from 12 of the 34 phones during a two-month time period in 1993. Seven of the 12 phones were ownded by the central actor, who used multiple phones to evade detection.
library(igraph)
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
setwd("~/Penn State Data Analytics/INSC846-Network Predictive Analytics/Project")
Table1 <- read.csv('COCAINE_DEALING.csv', header=TRUE, row.name=1)
head(Table1)
## Bill Blacky Bruce Charles Dante David Donald Doug Fabio Frank
## Bill 0 0 0 0 0 0 0 0 0 0
## Blacky 0 0 0 0 1 0 0 0 0 1
## Bruce 0 0 0 0 0 0 0 0 0 0
## Charles 0 0 0 0 0 0 0 0 0 0
## Dante 0 0 0 0 0 0 0 0 0 0
## David 0 0 0 0 0 0 0 0 0 0
## Gabriel Howard Jenny Kay Lara Lorena Louis Marky Marzio Menna
## Bill 0 0 0 0 0 0 0 0 0 0
## Blacky 0 0 0 0 0 0 0 0 0 0
## Bruce 0 0 0 0 0 0 0 0 0 0
## Charles 0 0 0 0 0 0 0 0 0 0
## Dante 0 0 0 0 0 0 0 0 0 0
## David 0 0 0 0 0 0 0 0 0 0
## Peretta Peter Robert Rosa Ross Shawn Steve Tommy
## Bill 0 0 0 0 0 0 0 0
## Blacky 0 0 0 0 1 0 0 0
## Bruce 0 0 0 0 0 0 0 0
## Charles 0 0 0 0 0 0 0 0
## Dante 0 0 1 0 0 0 0 0
## David 0 0 0 0 0 0 0 0
dim(Table1)
## [1] 28 28
Answer: 28 individuals were identified during the construction of this network. Therefore, a 28 X 28 matrix was constructed that represents the number of phone conversations between individuals. # Summary of the adjacency matrix
relations <- as.matrix(read.csv('COCAINE_DEALING.csv', header =T, row.names = 1))
g <- graph.adjacency(relations, mode = "undirected", weighted = TRUE)
summary(g)
## IGRAPH b77d921 UNW- 28 40 --
## + attr: name (v/c), weight (e/n)
Plot the network
plot(g, layout = layout_with_kk, vertex.label.cex = 0.7, edge.width=E(g)$weight)
# o Analysis:
Topographical measures for characterizing and analyzing the network: a. Size b. Distance c. Diameter
#a
size_g <- length(V(g))
#b
average_distance_g <- mean_distance(g)
#c
diameter_g <- diameter(g)
basic_topography_g <- matrix(c(size_g, average_distance_g, diameter_g), nrow=1, ncol=3)
colnames(basic_topography_g) <- c('size', 'average distance', 'diameter')
as.table(basic_topography_g)
## size average distance diameter
## A 28.000000 2.071429 11.000000
#d and e
degree_centralization_g <- centralization.degree(g)$centralization
degree_sd_g <-sd(centralization.degree(g)$res)
closeness_centralization_g <- centralization.closeness(g)$centralization
closeness_sd_g <-sd(centralization.closeness(g)$res)
betweenness_centralization_g <- centralization.betweenness(g)$centralization
betweenness_sd_g <- sd(centralization.betweenness(g)$res)
centralization_g <- matrix(c(degree_centralization_g, degree_sd_g, closeness_centralization_g, closeness_sd_g, betweenness_centralization_g, betweenness_sd_g), nrow=1, ncol=6)
colnames(centralization_g) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
as.table(centralization_g)
## degree cent degree cent. SD closeness cent. closeness cent. SD
## A 0.78306878 4.41977279 0.85380923 0.09363356
## betweenness cent. betweenness cent. SD
## A 0.87759840 58.86250907
#f
density_g <- edge_density(g)
#g
average_degree_g <- mean(degree(g))
#h
cohesion_g <- cohesion(g)
#i
compactness_g <- mean(closeness(g))
#j
global_clustering_coefficient_g <- transitivity(g,type="global")
interconnectedness_g <- matrix(c(density_g, average_degree_g, cohesion_g, compactness_g, global_clustering_coefficient_g), nrow=1, ncol=5)
colnames(interconnectedness_g) <- c('density', 'average degree', 'cohesion', 'compactness', 'global clustering coefficient')
as.table(interconnectedness_g)
## density average degree cohesion compactness
## A 0.105820106 2.857142857 1.000000000 0.008825097
## global clustering coefficient
## A 0.124260355
Cohesive subgroups measures
Summary of the adjacency matrix
relations <- as.matrix(read.csv('COCAINE_DEALING.csv', header =T, row.names = 1))
g <- graph.adjacency(relations, mode = "undirected", weighted = TRUE)
summary(g)
## IGRAPH b7ac8b7 UNW- 28 40 --
## + attr: name (v/c), weight (e/n)
#Are networks weakly or strongly connected
weakly_connected_g <- is.connected(g, mode="weak")
strongly_connected_g <- is.connected(g, mode="strong")
#Get the number of (weakly or strongly) connected components
number_weak_components_g <- clusters(g, mode="weak")$no
size_weak_components_g <-clusters(g, mode="weak")$csize
members_weak_components_g <- clusters(g, mode="weak")$membership
number_strong_components_g <- clusters(g, mode="strong")$no
size_strong_components_g <-clusters(g, mode="strong")$csize
members_strong_components_g <- clusters(g, mode="strong")$membership
cat("Summary of component measures for first network: \n",
"Is weakly connected? ", weakly_connected_g, "\n",
"Is strongly connected? ", strongly_connected_g, "\n",
"Number of weak components: ", number_weak_components_g, "\n",
"Size of weak components: ", size_weak_components_g, "\n",
"Member of weak components: ", members_weak_components_g, "\n",
"Number of strong components: ", number_strong_components_g, "\n",
"Size of strong components: ", size_strong_components_g, "\n",
"Member of strong components: ", members_strong_components_g, "\n\n")
## Summary of component measures for first network:
## Is weakly connected? TRUE
## Is strongly connected? TRUE
## Number of weak components: 1
## Size of weak components: 28
## Member of weak components: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## Number of strong components: 1
## Size of strong components: 28
## Member of strong components: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Component analysis reveals that the network is weakly connected. # b. Cliques
# List of cliques, their sizes and cliques with largest number of nodes
cliques_g <- cliques(g, min=3)
clique_sizes_g <- sapply(cliques_g, length)
largest_cliques_g <- largest_cliques(g)
cat("Summary of clique measures (smallest clique size 3) for first network: \n",
"Number of cliques: ", length(cliques_g), "\n",
"Cliques ", paste(cliques_g[[1]]), "\n",
" ", paste(cliques_g[[2]]), "\n",
" ", paste(cliques_g[[3]]), "\n",
" ", paste(cliques_g[[4]]), "\n",
" ", paste(cliques_g[[5]]), "\n",
" ", paste(cliques_g[[6]]), "\n",
"Clique sizes ", paste(clique_sizes_g), "\n",
"Largest clique: ", paste(largest_cliques_g), "\n")
## Summary of clique measures (smallest clique size 3) for first network:
## Number of cliques: 15
## Cliques 14 20 21
## 2 14 20
## 14 20 28
## 2 14 25
## 14 22 27
## 14 19 28
## Clique sizes 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3
## Largest clique: c(Kay = 14, Frank = 10, Blacky = 2, Menna = 20)
There are fifteen cliques. The largest clique contains Kay, Frank, Blacky and Menna. # c. Cores #3 cores
par(mfrow=c(1,2), mar=c(2,2,2,2))
plot(g, vertex.color = graph.coreness(g), edge.curved=0)
There are three cores in the network. # # Summary of the adjacency matrix
relations <- as.matrix(read.csv('COCAINE_DEALING.csv', header =T, row.names = 1))
g <- graph.adjacency(relations, mode = "undirected", weighted = TRUE)
summary(g)
## IGRAPH b7d6616 UNW- 28 40 --
## + attr: name (v/c), weight (e/n)
par(mfrow=c(3,3), mar=c(2,2,2,2))
g <- simplify(g)
#Identifying communities using Girvan-Newman Edge Betweenness algorithm [for undirected graph only]
#Community structure detection based on the betweenness of the edges in the network
girvan_newman_communities_g <- edge.betweenness.community(g)
## Warning in edge.betweenness.community(g): At community.c:460 :Membership
## vector will be selected based on the lowest modularity score.
## Warning in edge.betweenness.community(g): At community.c:467 :Modularity
## calculation with weighted edge betweenness community detection might not
## make sense -- modularity treats edge weights as similarities while edge
## betwenness treats them as distances
#Identifying communities using Clauset Newman and Moore
#Community structure detection via fast greedy modularity optimization algorithm
#fast-greedy community finding works only on graphs without multiple edges
cnm_communities_g <- cluster_fast_greedy(g, merges = TRUE, modularity = TRUE, membership = TRUE)
#Identifying communities using Walktrap
#Community structure detection based on the random walks
walktrap_communities_g <- walktrap.community(g,modularity = TRUE)
plot(as.dendrogram(girvan_newman_communities_g), main="g: Girvan-NewMan")
plot(as.dendrogram(cnm_communities_g), main="g: CNM")
plot(as.dendrogram(walktrap_communities_g), main="g: Walktrap")
The three types of community detection (Girvan Newman,CNM and Walktrap) showed, at the highest level of the hierarchy, differences in the number of distinct communities. # Central actor or brokerage measures
Plot the network showing the articulation points
g.ap <- articulation.points(g)
cat("Articulation points: ", V(g)$name[g.ap], "\n")
## Articulation points: Dante Steve Tommy Kay
Articulation points include Dante, Steve, Tommy and Kay.
g1 <- delete.vertices(g, g.ap)
plot(g1)
g.ap1 <- articulation.points(g)
cat("Articulation points: ", ifelse((length(V(g)$name[g.ap]) == 0),"none", V(g)$name[g.ap]), "\n")
## Articulation points: Dante
g2 <- delete.vertices(g, g.ap1)
plot(g2)
Plot the network showing biconnected components
g.bc <- biconnected.components(g)
cat("Number of biconnected components: ", g.bc$no, "\n")
## Number of biconnected components: 15
Determine the largest biconnected component as follows:
#determine the largest component
lc <- which.max(sapply(g.bc$components, length))
#color the actors of the largest component salmon and the rest skyblue
V(g)$color <- "blue"
V(g)[g.bc$components[[lc]]]$color <- "red"
#plot the network
plot(g, vertex.size=10, vertex.label.cex=0.6, vertex.label.color="black", edge.arrow.size=.4, layout=layout_with_fr, main ="Drug Trafficking Biconnected Components")
Plot the network showing key players that would fragment the network most
How will the network look if these key players are removed?
library(keyplayer)
##
## Attaching package: 'keyplayer'
## The following object is masked from 'package:igraph':
##
## contract
g.matrix <- as.matrix(get.adjacency(g))
g.fragment <- kpset(g.matrix, size = 6, type = "fragment")
V(g)$color <- "blue"
V(g)$color[g.fragment$keyplayers] <- "red"
plot(g, mark.groups=g.fragment$keyplayers, mark.col=NA, mark.border="black")
g.fragment$keyplayers
## [1] 2 5 14 20 27 28
g[1]
## Bill Blacky Bruce Charles Dante David Donald Doug Fabio
## 0 0 0 0 0 0 0 0 0
## Frank Gabriel Howard Jenny Kay Lara Lorena Louis Marky
## 0 0 0 0 2 0 0 0 0
## Marzio Menna Peretta Peter Robert Rosa Ross Shawn Steve
## 0 0 0 0 0 0 0 0 0
## Tommy
## 0
Key players: Blacky, Dante, Kay, Menna, Steve, Tommy If the key player actors are removed, the network will be reduced to minimal structure.
plot(delete.vertices(g, g.fragment$keyplayers))
Key players: Blacky, Dante, Kay, Menna, Steve, Tommy
Try to delete any of the actors from this biconnected component and see if it disrupts the network.
g3 = delete.vertices(g, "Kay")
plot(g3)
Remove Kay and Tommy
g4 = delete.vertices(g, "Kay") %>%
delete_vertices("Tommy")
plot(g4)
Remove Kay, Tommy and Blacky
g5 = delete.vertices(g, "Kay") %>%
delete_vertices("Tommy")%>%
delete_vertices("Blacky")
plot(g5)
Remove Kay,Tommy, Blacky and Menna
g6 = delete.vertices(g, "Kay") %>%
delete_vertices("Tommy")%>%
delete_vertices("Blacky")%>%
delete_vertices("Menna")
plot(g6)
Remove Kay,Tommy, Blacky,Menna and Steve
g7 = delete.vertices(g, "Kay") %>%
delete_vertices("Tommy")%>%
delete_vertices("Blacky")%>%
delete_vertices("Menna")%>%
delete_vertices("Steve")
plot(g7)
Remove Kay,Tommy, Blacky,Menna and Steve and Dante
g8 = delete.vertices(g, "Kay") %>%
delete_vertices("Tommy")%>%
delete_vertices("Blacky")%>%
delete_vertices("Menna")%>%
delete_vertices("Steve")%>%
delete_vertices("Dante")
plot(g8)
Plot the network visualizing structural holes by displaying how constrained the actors are in the network.
When the least constrained actors are removed, The network has smaller nodes which has higher brokerage potential. It is less constrained.
g.constraint <- constraint(g)
plot(g, vertex.size = 7*g.constraint)
#
library('igraph')
net <- graph_from_data_frame(d=relations, directed=F)
net
## IGRAPH bca76ca UN-- 3 28 --
## + attr: name (v/c), Bruce (e/n), Charles (e/n), Dante (e/n), David
## | (e/n), Donald (e/n), Doug (e/n), Fabio (e/n), Frank (e/n),
## | Gabriel (e/n), Howard (e/n), Jenny (e/n), Kay (e/n), Lara (e/n),
## | Lorena (e/n), Louis (e/n), Marky (e/n), Marzio (e/n), Menna
## | (e/n), Peretta (e/n), Peter (e/n), Robert (e/n), Rosa (e/n),
## | Ross (e/n), Shawn (e/n), Steve (e/n), Tommy (e/n)
## + edges from bca76ca (vertex names):
## [1] 0--0 0--0 0--0 0--0 0--0 0--0 0--0 0--0 0--0 0--0 0--0
## [12] 0--0 0--0 2--10 0--0 0--0 0--0 0--0 0--0 0--2 0--0 0--0
## [23] 0--0 0--0 0--0 0--0 0--0 0--0
g
## IGRAPH b7dc8a1 UNW- 28 40 --
## + attr: name (v/c), color (v/c), weight (e/n)
## + edges from b7dc8a1 (vertex names):
## [1] Bill --Kay Blacky --Dante Blacky --Frank Blacky --Kay
## [5] Blacky --Menna Blacky --Ross Bruce --Kay Charles--Kay
## [9] Dante --Kay Dante --Robert David --Kay David --Tommy
## [13] Donald --Kay Donald --Tommy Doug --Kay Fabio --Kay
## [17] Fabio --Steve Fabio --Tommy Frank --Kay Frank --Menna
## [21] Gabriel--Kay Howard --Kay Jenny --Kay Kay --Lara
## [25] Kay --Lorena Kay --Louis Kay --Marky Kay --Marzio
## [29] Kay --Menna Kay --Peretta Kay --Peter Kay --Ross
## + ... omitted several edges
The description of an igraph object starts with four letters: 1. D or U, for a directed or undirected graph 2. N for a named graph (where nodes have a name attribute) 3. W for a weighted graph (where edges have a weight attribute) 4. B for a bipartite (two-mode) graph (where nodes have a type attribute) The two numbers that follow (3 28) refer to the number of nodes and edges in the graph. The description also lists node & edge attributes, for example: . (g/c) - graph-level character attribute . (v/c) - vertex-level character attribute . (e/n) - edge-level numeric attribute
You might notice that we could have used simplify to combine multiple edges by summing their weights with a command like simplify(net, edge.attr.comb=list(Weight=“sum”,“ignore”)). The problem is that this would also combine multiple edge types (in our data: “hyperlinks” and “mentions”).
net1 <- simplify(g, remove.multiple = F, remove.loops = F)
net2 <- simplify(g, edge.attr.comb=list(Weight="sum","ignore"))
Reduce the arrow size and remove the labels (by setting them to NA):
plot(g, layout = layout_with_kk, vertex.label.cex = 0.7, edge.width=E(g)$weight)
plot(net1, edge.arrow.size=.4,vertex.label=NA)
plot(net2, edge.arrow.size=.4,vertex.label=NA)
Color the edges of the graph based on their source node color. We get the starting node for each edge with the ends() igraph function. It returns the start and end vertex for edges listed in the es parameter. The names parameter control whether the function returns edge names or IDs.
edge.start <- ends(g, es=E(g), names=F)[,1]
edge.col <- V(g)$color[edge.start]
plot(g, edge.color=edge.col, edge.curved=.1)
# Take a look at all available layouts in igraph:
layouts <- grep("^layout_", ls("package:igraph"), value=TRUE)[-1]
# Remove layouts that do not apply to our graph.
layouts <- layouts[!grepl("bipartite|merge|norm|sugiyama|tree", layouts)]
par(mfrow=c(3,3), mar=c(1,1,1,1))
for (layout in layouts) {
print(layout)
l <- do.call(layout, list(g))
plot(g, edge.arrow.mode=0, layout=l, main=layout) }
## [1] "layout_as_star"
## [1] "layout_components"
## [1] "layout_in_circle"
## [1] "layout_nicely"
## [1] "layout_on_grid"
## [1] "layout_on_sphere"
## [1] "layout_randomly"
## [1] "layout_with_dh"
## [1] "layout_with_drl"
## [1] "layout_with_fr"
## [1] "layout_with_gem"
## [1] "layout_with_graphopt"
## [1] "layout_with_kk"
## [1] "layout_with_lgl"
## [1] "layout_with_mds"
layouts <- grep("^layout_", ls("package:igraph"), value=TRUE)[-1]
# Remove layouts that do not apply to our graph.
layouts <- layouts[!grepl("bipartite|merge|norm|sugiyama|tree", layouts)]
par(mfrow=c(3,3), mar=c(1,1,1,1))
for (layout in layouts) {
print(layout)
l <- do.call(layout, list(net1))
plot(net1, edge.arrow.mode=0, layout=l, main=layout) }
## [1] "layout_as_star"
## [1] "layout_components"
## [1] "layout_in_circle"
## [1] "layout_nicely"
## [1] "layout_on_grid"
## [1] "layout_on_sphere"
## [1] "layout_randomly"
## [1] "layout_with_dh"
## [1] "layout_with_drl"
## [1] "layout_with_fr"
## [1] "layout_with_gem"
## [1] "layout_with_graphopt"
## [1] "layout_with_kk"
## [1] "layout_with_lgl"
## [1] "layout_with_mds"
layouts <- grep("^layout_", ls("package:igraph"), value=TRUE)[-1]
# Remove layouts that do not apply to our graph.
layouts <- layouts[!grepl("bipartite|merge|norm|sugiyama|tree", layouts)]
par(mfrow=c(3,3), mar=c(1,1,1,1))
for (layout in layouts) {
print(layout)
l <- do.call(layout, list(net2))
plot(net2, edge.arrow.mode=0, layout=l, main=layout) }
## [1] "layout_as_star"
## [1] "layout_components"
## [1] "layout_in_circle"
## [1] "layout_nicely"
## [1] "layout_on_grid"
## [1] "layout_on_sphere"
## [1] "layout_randomly"
## [1] "layout_with_dh"
## [1] "layout_with_drl"
## [1] "layout_with_fr"
## [1] "layout_with_gem"
## [1] "layout_with_graphopt"
## [1] "layout_with_kk"
## [1] "layout_with_lgl"
## [1] "layout_with_mds"
plot(g, layout = layout_with_drl, vertex.label.cex = 0.7, edge.width=E(g)$weight)
plot(g, layout = layout_as_star, vertex.label.cex = 0.7, edge.width=E(g)$weight)
library(threejs)
library(htmlwidgets)
library(igraph)
g.net <- graphjs(g, main = "NYC Cocaine Trafficking Ring", showLabels = T, bg="black")
g.net3 <- graphjs(g3, main = "NYC Cocaine Trafficking Ring - Remove Kay", showLabels = T, bg="black")
g.net4 <- graphjs(g4, main = "NYC Cocaine Trafficking Ring - Remove Kay & Tommy", showLabels = T, bg="black")
g.net5 <- graphjs(g5, main = "NYC Cocaine Trafficking Ring - Remove Kay, Tommy & Blacky", showLabels = T, bg="black")
g.net6 <- graphjs(g6, main = "NYC Cocaine Trafficking Ring - Remove Kay, Tommy, Blacky & Menna", showLabels = T, bg="black")
g.net7 <- graphjs(g7, main = "NYC Cocaine Trafficking Ring - Remove Kay, Tommy, Blacky, Menna & Steve", showLabels = T, bg="black")
g.net8 <- graphjs(g8, main = "NYC Cocaine Trafficking Ring - Remove Key Actors", showLabels = T, bg="black")
saveWidget(g.net, file="NYC Cocaine Trafficking Ring-gjs.html")
saveWidget(g.net3, file="Remove Kay-gjs.html")
saveWidget(g.net4, file="Remove Kay & Tommy-gjs.html")
saveWidget(g.net5, file="Remove Kay, Tommy & Blacky-gjs.html")
saveWidget(g.net6, file="Remove Kay, Tommy, Blacky & Menna-gjs.html")
saveWidget(g.net7, file="Remove Kay, Tommy, Blacky, Menna & Steve-gjs.html")
saveWidget(g.net8, file="Remove Key Actors-gjs.html")
browseURL("NYC Cocaine Trafficking Ring-gjs.html")
browseURL("Remove Kay-gjs.html")
browseURL("Remove Kay & Tommy-gjs.html")
browseURL("Remove Kay, Tommy & Blacky-gjs.html")
browseURL("Remove Kay, Tommy, Blacky & Menna-gjs.html")
browseURL("Remove Kay, Tommy, Blacky, Menna & Steve-gjs.html")
browseURL("Remove Key Actors-gjs.html")
Examining measures between removal of actors
#d and e
degree_centralization_g <- centralization.degree(g)$centralization
degree_sd_g <-sd(centralization.degree(g)$res)
closeness_centralization_g <- centralization.closeness(g)$centralization
closeness_sd_g <-sd(centralization.closeness(g)$res)
betweenness_centralization_g <- centralization.betweenness(g)$centralization
betweenness_sd_g <- sd(centralization.betweenness(g)$res)
centralization_g <- matrix(c(degree_centralization_g, degree_sd_g, closeness_centralization_g, closeness_sd_g, betweenness_centralization_g, betweenness_sd_g), nrow=1, ncol=6)
colnames(centralization_g) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g3
degree_centralization_g3 <- centralization.degree(g3)$centralization
degree_sd_g3 <-sd(centralization.degree(g3)$res)
closeness_centralization_g3 <- centralization.closeness(g3)$centralization
## Warning in centralization.closeness(g3): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g3 <-sd(centralization.closeness(g3)$res)
## Warning in centralization.closeness(g3): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g3 <- centralization.betweenness(g3)$centralization
betweenness_sd_g3 <- sd(centralization.betweenness(g3)$res)
centralization_g3 <- matrix(c(degree_centralization_g3, degree_sd_g3, closeness_centralization_g3, closeness_sd_g3, betweenness_centralization_g3, betweenness_sd_g3), nrow=1, ncol=6)
colnames(centralization_g3) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g4
degree_centralization_g4 <- centralization.degree(g4)$centralization
degree_sd_g4 <-sd(centralization.degree(g4)$res)
closeness_centralization_g4 <- centralization.closeness(g4)$centralization
## Warning in centralization.closeness(g4): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g4 <-sd(centralization.closeness(g4)$res)
## Warning in centralization.closeness(g4): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g4 <- centralization.betweenness(g4)$centralization
betweenness_sd_g4 <- sd(centralization.betweenness(g4)$res)
centralization_g4 <- matrix(c(degree_centralization_g4, degree_sd_g4, closeness_centralization_g4, closeness_sd_g4, betweenness_centralization_g4, betweenness_sd_g4), nrow=1, ncol=6)
colnames(centralization_g4) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g5
degree_centralization_g5 <- centralization.degree(g5)$centralization
degree_sd_g5 <-sd(centralization.degree(g5)$res)
closeness_centralization_g5 <- centralization.closeness(g5)$centralization
## Warning in centralization.closeness(g5): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g5 <-sd(centralization.closeness(g5)$res)
## Warning in centralization.closeness(g5): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g5 <- centralization.betweenness(g5)$centralization
betweenness_sd_g5 <- sd(centralization.betweenness(g5)$res)
centralization_g5 <- matrix(c(degree_centralization_g5, degree_sd_g5, closeness_centralization_g5, closeness_sd_g5, betweenness_centralization_g5, betweenness_sd_g5), nrow=1, ncol=6)
colnames(centralization_g5) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g6
degree_centralization_g6 <- centralization.degree(g6)$centralization
degree_sd_g6 <-sd(centralization.degree(g6)$res)
closeness_centralization_g6 <- centralization.closeness(g6)$centralization
## Warning in centralization.closeness(g6): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g6 <-sd(centralization.closeness(g6)$res)
## Warning in centralization.closeness(g6): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g6 <- centralization.betweenness(g6)$centralization
betweenness_sd_g6 <- sd(centralization.betweenness(g6)$res)
centralization_g6 <- matrix(c(degree_centralization_g6, degree_sd_g6, closeness_centralization_g6, closeness_sd_g6, betweenness_centralization_g6, betweenness_sd_g6), nrow=1, ncol=6)
colnames(centralization_g6) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g7
degree_centralization_g7 <- centralization.degree(g7)$centralization
degree_sd_g7 <-sd(centralization.degree(g7)$res)
closeness_centralization_g7 <- centralization.closeness(g7)$centralization
## Warning in centralization.closeness(g7): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g7 <-sd(centralization.closeness(g7)$res)
## Warning in centralization.closeness(g7): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g7 <- centralization.betweenness(g7)$centralization
betweenness_sd_g7 <- sd(centralization.betweenness(g7)$res)
centralization_g7 <- matrix(c(degree_centralization_g7, degree_sd_g7, closeness_centralization_g7, closeness_sd_g7, betweenness_centralization_g7, betweenness_sd_g7), nrow=1, ncol=6)
colnames(centralization_g7) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
#g8
degree_centralization_g8 <- centralization.degree(g8)$centralization
degree_sd_g8 <-sd(centralization.degree(g8)$res)
closeness_centralization_g8 <- centralization.closeness(g8)$centralization
## Warning in centralization.closeness(g8): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
closeness_sd_g8 <-sd(centralization.closeness(g8)$res)
## Warning in centralization.closeness(g8): At centrality.c:2784 :closeness
## centrality is not well-defined for disconnected graphs
betweenness_centralization_g8 <- centralization.betweenness(g8)$centralization
betweenness_sd_g8 <- sd(centralization.betweenness(g8)$res)
centralization_g8 <- matrix(c(degree_centralization_g8, degree_sd_g8, closeness_centralization_g8, closeness_sd_g8, betweenness_centralization_g8, betweenness_sd_g8), nrow=1, ncol=6)
colnames(centralization_g8) <- c('degree cent', 'degree cent. SD', 'closeness cent.', 'closeness cent. SD', 'betweenness cent.', 'betweenness cent. SD')
as.table(centralization_g)
## degree cent degree cent. SD closeness cent. closeness cent. SD
## A 0.78306878 4.41977279 0.85380923 0.09363356
## betweenness cent. betweenness cent. SD
## A 0.87759840 58.86250907
centralization <- rbind(centralization_g, centralization_g3, centralization_g4, centralization_g5, centralization_g6, centralization_g7, centralization_g8)
rownames(centralization) <- c('g', 'g3','g4','g5','g6','g7','g8')
as.table(centralization)
## degree cent degree cent. SD closeness cent. closeness cent. SD
## g 7.830688e-01 4.419773e+00 8.538092e-01 9.363356e-02
## g3 1.851852e-01 1.520046e+00 4.137565e-02 1.945853e-02
## g4 1.292308e-01 1.142198e+00 1.621717e-02 4.813490e-03
## g5 1.050000e-01 7.702813e-01 8.637882e-03 2.096535e-03
## g6 1.159420e-01 7.019641e-01 1.031741e-02 2.200450e-03
## g7 4.150198e-02 2.881041e-01 3.862738e-03 5.693756e-04
## g8 0.000000e+00 0.000000e+00 3.251367e-17 0.000000e+00
## betweenness cent. betweenness cent. SD
## g 8.775984e-01 5.886251e+01
## g3 2.194083e-01 2.045445e+01
## g4 3.493333e-02 2.512737e+00
## g5 1.071860e-02 6.244998e-01
## g6 1.185771e-02 6.123724e-01
## g7 0.000000e+00 0.000000e+00
## g8 0.000000e+00 0.000000e+00